[opensuse] installing python from source
I want to set up a python virtual environment with a version of python that I have installed from source, independent of the repositories. The reason for this is that I am running tumbleweed on one pc, Leap 15.0 on another, and will plan to upgrade to Leap 15.2 on another when it is available. Tumbleweed gets the latest version of python that is available, and this last time it replaced all my 3.6 binaries with 3.7 binaries, so I want to avoid that in the future. I am working on a long term project, and I need to maintain a python environment that is independent of repository updates. So I figured I would do that with a virtual environment that is based on something I have installed from source. I am open to other ideas also. I tried installing python 3.7.2 in my Leap 15 laptop based on the guide at this URL: https://realpython.com/installing-python/#compiling-python-from-source That put the new python 3.7.2 into the directory /usr/local/bin instead of /usr/bin. Also, somehow it doesn't seem to pull in everything necessary. When I try to set up the virtual environment with the command virtualenv -p /usr/local/bin/python3.7 .smdellvenv it comes up with the error :
virtualenv -p /usr/local/bin/python3.7 .smdellvenv Running virtualenv with interpreter /usr/local/bin/python3.7 Could not find platform dependent libraries <exec_prefix> Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>] Traceback (most recent call last): File "/usr/lib/python3.6/site-packages/virtualenv.py", line 16, in <module> import base64 File "/usr/local/lib/python3.7/base64.py", line 10, in <module> import struct File "/usr/local/lib/python3.7/struct.py", line 13, in <module> from _struct import * ModuleNotFoundError: No module named '_struct'
So I tried to change the PYTHONHOME variable like this:
export PYTHONHOME="/usr/local/bin/python3.7"
Now, when I run the virtualenv command, this is what happens:
virtualenv -p /usr/local/bin/python3.7 .smdellvenv Fatal Python error: Py_Initialize: Unable to get the locale encoding ModuleNotFoundError: No module named 'encodings'
Current thread 0x00007f06c17f2540 (most recent call first): Aborted (core dumped) Anyone have any success with installing python from source? Do I need to build my own full set of packages, or perhaps download what is available on the build service? Any help would be greatly appreciated. Thanks, George -- George Box: TW | Plasma 5 | AMD Phenom IIX4 | 64 | 32GB Laptop #1: TW | Plasma 5 | AMD FX 7TH GEN | 64 | 32GB Laptop #2: 15.0 | Plasma 5 | Core i5 | 64 | 8GB -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org
On Mon, 1 Apr 2019 14:02:06 -0500 George from the tribe wrote: 8< - - - - - trimmed - - - - - >8
Anyone have any success with installing python from source? Do I need to build my own full set of packages, or perhaps download what is available on the build service? Any help would be greatly appreciated.
Hi George, Have you investigated Docker? You could probably fork an existing image to create *exactly* the development environment that you want, than use your new image to launch literally identical instances of it on each, disparate system. This is a very common, even mundane arrangement using Docker. regards, Carl
Thanks, George
-- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org
Have you tried pyenv (https://github.com/pyenv/pyenv, it's also available in repo)? In my job I'm working on a project that is not compatible with python 3.7 yet, so after Tumbleweed (which I use at work) got updated to it, I had to find a way to install python 3.6. With pyenv you can easily have multiple python versions installed and create virtualenvs that uses them. Adam Mizerski W dniu 01.04.2019 o 21:02, George from the tribe pisze:
I want to set up a python virtual environment with a version of python that I have installed from source, independent of the repositories. The reason for this is that I am running tumbleweed on one pc, Leap 15.0 on another, and will plan to upgrade to Leap 15.2 on another when it is available. Tumbleweed gets the latest version of python that is available, and this last time it replaced all my 3.6 binaries with 3.7 binaries, so I want to avoid that in the future.
I am working on a long term project, and I need to maintain a python environment that is independent of repository updates. So I figured I would do that with a virtual environment that is based on something I have installed from source. I am open to other ideas also.
I tried installing python 3.7.2 in my Leap 15 laptop based on the guide at this URL: https://realpython.com/installing-python/#compiling-python-from-source
That put the new python 3.7.2 into the directory /usr/local/bin instead of /usr/bin.
Also, somehow it doesn't seem to pull in everything necessary. When I try to set up the virtual environment with the command virtualenv -p /usr/local/bin/python3.7 .smdellvenv
it comes up with the error :
virtualenv -p /usr/local/bin/python3.7 .smdellvenv Running virtualenv with interpreter /usr/local/bin/python3.7 Could not find platform dependent libraries <exec_prefix> Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>] Traceback (most recent call last): File "/usr/lib/python3.6/site-packages/virtualenv.py", line 16, in <module> import base64 File "/usr/local/lib/python3.7/base64.py", line 10, in <module> import struct File "/usr/local/lib/python3.7/struct.py", line 13, in <module> from _struct import * ModuleNotFoundError: No module named '_struct'
So I tried to change the PYTHONHOME variable like this:
export PYTHONHOME="/usr/local/bin/python3.7"
Now, when I run the virtualenv command, this is what happens:
virtualenv -p /usr/local/bin/python3.7 .smdellvenv Fatal Python error: Py_Initialize: Unable to get the locale encoding ModuleNotFoundError: No module named 'encodings'
Current thread 0x00007f06c17f2540 (most recent call first): Aborted (core dumped)
Anyone have any success with installing python from source? Do I need to build my own full set of packages, or perhaps download what is available on the build service? Any help would be greatly appreciated.
Thanks, George
On 4/3/19 2:42 PM, Adam Mizerski wrote:
Have you tried pyenv (https://github.com/pyenv/pyenv, it's also available in repo)?
In my job I'm working on a project that is not compatible with python 3.7 yet, so after Tumbleweed (which I use at work) got updated to it, I had to find a way to install python 3.6.
With pyenv you can easily have multiple python versions installed and create virtualenvs that uses them.
Adam Mizerski
W dniu 01.04.2019 o 21:02, George from the tribe pisze:
I want to set up a python virtual environment with a version of python that I have installed from source, independent of the repositories. The reason for this is that I am running tumbleweed on one pc, Leap 15.0 on another, and will plan to upgrade to Leap 15.2 on another when it is available. Tumbleweed gets the latest version of python that is available, and this last time it replaced all my 3.6 binaries with 3.7 binaries, so I want to avoid that in the future.
I am working on a long term project, and I need to maintain a python environment that is independent of repository updates. So I figured I would do that with a virtual environment that is based on something I have installed from source. I am open to other ideas also.
I tried installing python 3.7.2 in my Leap 15 laptop based on the guide at this URL: https://realpython.com/installing-python/#compiling-python-from-source
That put the new python 3.7.2 into the directory /usr/local/bin instead of /usr/bin.
Also, somehow it doesn't seem to pull in everything necessary. When I try to set up the virtual environment with the command virtualenv -p /usr/local/bin/python3.7 .smdellvenv
it comes up with the error :
virtualenv -p /usr/local/bin/python3.7 .smdellvenv Running virtualenv with interpreter /usr/local/bin/python3.7 Could not find platform dependent libraries <exec_prefix> Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>] Traceback (most recent call last): File "/usr/lib/python3.6/site-packages/virtualenv.py", line 16, in <module> import base64 File "/usr/local/lib/python3.7/base64.py", line 10, in <module> import struct File "/usr/local/lib/python3.7/struct.py", line 13, in <module> from _struct import * ModuleNotFoundError: No module named '_struct'
So I tried to change the PYTHONHOME variable like this:
export PYTHONHOME="/usr/local/bin/python3.7"
Now, when I run the virtualenv command, this is what happens:
virtualenv -p /usr/local/bin/python3.7 .smdellvenv Fatal Python error: Py_Initialize: Unable to get the locale encoding ModuleNotFoundError: No module named 'encodings'
Current thread 0x00007f06c17f2540 (most recent call first): Aborted (core dumped)
Anyone have any success with installing python from source? Do I need to build my own full set of packages, or perhaps download what is available on the build service? Any help would be greatly appreciated.
Thanks, George
A bit of a delayed response, but I thought I would follow up here. Thanks to all of you that responded. I did figure out how to use pyenv, and it seems to be the most workable solution for me. I followed the guidelines from this page: https://realpython.com/intro-to-pyenv/#why-use-pyenv Really good guidelines, and helpful, much less cumbersome than the way I was doing it. -- George Box: TW | Plasma 5 | AMD Phenom IIX4 | 64 | 32GB Laptop #1: TW | Plasma 5 | AMD FX 7TH GEN | 64 | 32GB Laptop #2: 15.0 | Plasma 5 | Core i5 | 64 | 8GB -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org
Hello, On Mon, 01 Apr 2019, George from the tribe wrote:
virtualenv -p /usr/local/bin/python3.7 .smdellvenv Running virtualenv with interpreter /usr/local/bin/python3.7 Could not find platform dependent libraries <exec_prefix> Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>] Traceback (most recent call last): File "/usr/lib/python3.6/site-packages/virtualenv.py", line 16, in <module> import base64 File "/usr/local/lib/python3.7/base64.py", line 10, in <module> import struct File "/usr/local/lib/python3.7/struct.py", line 13, in <module> from _struct import * ModuleNotFoundError: No module named '_struct'
So I tried to change the PYTHONHOME variable like this:
export PYTHONHOME="/usr/local/bin/python3.7"
RTFM. ==== man 1 python ==== PYTHONHOME [..] and ${exec_prefix}. To specify different values for these, set $PYTHONHOME to ${prefix}:${exec_prefix}. PYTHONPATH [..] path is installation depen- dent, but generally begins with ${prefix}/lib/python<version> (see PYTHONHOME above). The default search path is always appended to $PYTHONPATH. If a script argument is given, the ==== So: export PYTHONHOME="/usr/local" and/or: export PYTHONPATH="/usr/local/lib/python3.7" HTH, -dnh -- A tangled cable is a happy cable. -- R. B. West -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org
participants (4)
-
Adam Mizerski
-
Carl Hartung
-
David Haller
-
George from the tribe