2
votes

I install python from source:

$ wget -c https://www.python.org/ftp/python/3.6.1/Python-3.6.1.tar.xz   
$ tar xf Python-3.6.1.tar.xz  
$ cd Python-3.6.1  
$ ./configure --enable-optimizations --prefix=$HOME/.local/ --with-pydebug  
$ make altinstall -j8  

Then I install pip with get-pip.py

$ python3.6 get-pip.py --prefix=~/.local/

I met the error of:

Traceback (most recent call last): File "get-pip.py", line 27, in
import struct File "/home/zhangzy/.local/lib/python3.6/struct.py", line 13, in
from _struct import * ModuleNotFoundError: No module named '_struct'

What is the cause of this problem and how could it solve it?

1

1 Answers

-1
votes

You should always use your system package manager when possible. There is a safe way to get newer versions of Python on CentOS/RHEL, as proper RPM packages. It is called the IUS project, and we offer multiple versions of Python.

After setting up the repo, you can get Python 3.5 by running the command yum install python35u. You will then have the command python3.5 available, as well as the pyvenv-3.5 command for creating virtual environments.