Question

I'm new to both python, pythonbrew and ubuntu. I need python 2.6 and currently have 2.7 on my ubuntu precise system. Searching online revealed that I should not try to uninstall 2.7 as that would pretty much destroy the OS, but get pythonbrew instead, that manages multiple python installations.

I tried installing pythonbrew, but the curl install (curl -kL https://raw.githubusercontent.com/utahta/pythonbrew/master/pythonbrew-install | bash) did not work for me: it was not picking up my http proxy from env, and then not passing it to the install script, once I provided it on the command line. I downloaded the pythonbrew bits manually and then used python setup.py install to install it. I did it as root and it seemed to work (installing under /root/.pythonbrew, which was not the best), however I could not use it as a different user on the system (permission problems). After some more reading I executed the script correctly as root user and it installed pythonbrew to /usr/local/pythonbrew (yay).

Now, when I execute the following as root or non root user, it waits for a while and then the prompt comes back with no error or any other information (--verbose makes no difference):

root@xxx:~/.pythonbrew/scripts/pythonbrew# pythonbrew install 2.6
root@xxx:~/.pythonbrew/scripts/pythonbrew#

Any ideas? I'm guessing this has something to do with the proxy again, but I'm completely new to python so any pointers are welcome.

Was it helpful?

Solution

Following the "which pythonbrew" and doing some guessing the following solved my problem: I changed the curl.py file under /usr/local/pythonbrew/scripts/pythonbrew adding proxy setting to read, readheader and fetch functions as follows:

before modification:

 p = Popen('curl -skL "%s"' % url, stdout=PIPE, shell=True)

after modification:

 p = Popen('curl -x http://<proxy host>:<proxy port> -skL "%s"' % url, stdout=PIPE, shell=True)

I am not sure why there was no output without the proxy setting, but now the install works!

OTHER TIPS

I also faced this issue today, while installing py2.7.14 with pythonbrew.

The reason it silently fails to install is when it gets the header from the python server (src of py2.7.14), it checks for a return status of success. It implements HTTP/1.1 method check (only) where successful return status is 200 OK.

However, python server uses HTTP/2 and the success return code is in the form 200, there's no trailing OK.

So, to fix it, I added 2 lines of code below following 2 lines in /opt/.pythonbrew/scripts/pythonbrew/curl.py, routine readheader().

if re.match('^HTTP.*? 200 OK$', line):
    break

Added this code below above code:

elif re.match('^HTTP.*? 200$', line):
    break

I did't want to change pythonbrew's code, hence added it with an elif.

This works.

I note that several other people using pyenv also mentions of similar issue, I am presuming similar issue may exist there.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top