I am trying to build Python 2.7 from source on a CentOS 7 multi user system which has other installations of Python. I originally was building Python 2.7.15 with gcc 6.3.0 with the following flags:
./configure --prefix=/path/to/install --enable-shared --enable-optimizations
After running into some build errors I then tried:
./configure --prefix=/path/to/install --enable-shared --enable-optimizations --with-ensurepip --enable-unicode=ucs4
I am running into two major errors. First of all I have only ever set PYTHONPATH to the top level lib directory in the past. ex: PYTHONPATH=/path/to/python/lib/python2.7 With this build python cannot find the modules in lib-dynload unless I set PYTHONPATH=/path/to/python/lib/python2.7:/path/to/python/lib/python2.7/lib-dynload The second issue is (after setting the PYTHONPATH to include lib-dynload) when I try to run pip I get the following error from weakref.py: ImportError: cannot import name _remove_dead_weakref I'm not sure what other modules have errors, but I wouldn't be surprised if this wasn't isolated to weakref.py
I have tried the following modifications:
- Python 2.7.14
- gcc 4.8.5
- without the --enable-optimizations flag
- --with-ensurepip=update
Please don't respond with solutions that don't include building from source
UPDATE
I went into the commit history to see if I could find what release '_remove_dead_weakrefs' was added in. Python 2.7.14 was the first release with this code, Python 2.7.13 does not have it.
I was able to compile 2.7.13 on my system, and can now import weakref in python allowing me to run pip. In addition I do not have to point PYTHONPATH to the lib-dynload directory. I'll update again if I find other errors with this build, or if I find out why '_remove_dead_weakref' seemed to be broken for me.
I'm very curious why this is happening. If any Python experts out there have some insight I'd love to hear it