When I altinstall python 2.7.12 with
./configure --prefix=/opt/python --enable-shared
it comes up as python 2.7.5 (system default python)
But without
--enable-shared
it comes up as 2.7.12, what am I missing?
This is on RHEL 7.2
This is not a pathing issue:
Without --enable-shared
[root@myrig ~]# /opt/python/bin/python2.7 -V
Python 2.7.12
With --enable-shared
[root@myrig ~]# /opt/python/bin/python2.7 -V
Python 2.7.5
The -enable-shared option ensures to build both static and dynamic Python libraries. This option is mandatory for a correct behaviour of the Gildas-Python binding. The -prefix option allows you to install Python in a custom location (instead of /usr/local).
@NathanielFord It's the build time for Python itself that's slowed down by enabling the optimizations. Most source builds are debug ones for development purposes, so the default config settings favour faster binary builds at the expense of slightly slower test case execution times.
The Python Configuration can be used to build a customized Python which behaves as the regular Python. For example, environment variables and command line arguments are used to configure Python. The Isolated Configuration can be used to embed Python into an application.
Compiling python like this fixed my issue:
./configure --enable-shared --prefix=/opt/python LDFLAGS=-Wl,-rpath=/opt/python/lib
Courtesy Ned Deily:
The problem is, that on most Unix systems (with the notable exception of Mac OS X), the path to shared libraries is not an absolute path. So, if you install Python in a non-standard location, which is the right thing to do so as not to interfere with a system Python of the same version, you will need to configure in the path to the shared library or supply it via an environment variable at run time, like LD_LIBRARY_PATH. You may be better off avoiding --enable-shared; it's easy to run into problems like this with it.
Ref: https://bugs.python.org/issue27685
I'm not sure why the version number is different, but Graham Dumpleton says at this website that "When running configure, you should be supplying the --enable-shared option to ensure that shared libraries are built for Python. By not doing this you are preventing any application which wants to use Python as an embedded environment from working."
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With