Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Trying to upgrade Python 2.7.0 to Python 2.7.3 using pip: SyntaxError; confused between python2 and python3?

Tags:

python

pip

I have an installation of Python 2.7.0 in a virtualenv in /local/gerrit/python2.7. I'd like to upgrade this to Python 2.7.3. I'm trying to use pip for this, but somehow it seems to be confused between python2 and python3:

$ pip install --upgrade 'python>=2.7,<2.7.99'
Downloading/unpacking python>=2.7,<2.7.99 from http://www.python.org/ftp/python/2.7.3/Python-2.7.3.tar.bz2
  Running setup.py egg_info for package python
    Traceback (most recent call last):
      File "<string>", line 16, in <module>
      File "/local/gerrit/python2.7/build/python/setup.py", line 1804
        exec(f.read(), globals(), fficonfig)
    SyntaxError: unqualified exec is not allowed in function 'configure_ctypes' it contains a nested function with free variables
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):

  File "<string>", line 16, in <module>

  File "/local/gerrit/python2.7/build/python/setup.py", line 1804

    exec(f.read(), globals(), fficonfig)

SyntaxError: unqualified exec is not allowed in function 'configure_ctypes' it contains a nested function with free variables

----------------------------------------
Command python setup.py egg_info failed with error code 1 in /local/gerrit/python2.7/build/python
Storing complete log in /storage4/home/gerrit/.pip/pip.log

It looks like /local/gerrit/python2.7/build/python/setup.py actually has a python3 syntax, and something got messed up. Is my diagnosis correct? How do I clean this up in a way that doesn't require reinstalling Python and all its libraries?

like image 660
gerrit Avatar asked Aug 09 '26 19:08

gerrit


1 Answers

You will likely need to use something like pythonz which manages multiple python installation on the same machine.

Then when you are using things like virtualenv you will want to point them at the binary that you installed like so and you will have a working virtualenv with that specific copy of python

virtualenv -p /path/to/python

like image 177
myusuf3 Avatar answered Aug 12 '26 10:08

myusuf3



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!