Wow! The installation is so annoying, and finally found that it is the reason of my own network. Calm down and sum up! ! !
python is 3.6
centos 6 64 bit
1. Install python
https://blog.csdn.net/O_OKKk/article/details/80170471
2. Install pip
wget https://bootstrap.pypa.io/get-pip.py --no-check-certificate python get-pip.py
May be wrong! ! ! Such as:
pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.
Execute python and enter the python command line:
import ssl
may also report an error
import ssl
Traceback (most recent call last):
File “”, line 1, in
File “/usr/local/python27/lib/python2.7/ssl.py”, line 60, in
import _ssl # if we can’t import it, let the error propagate
ImportError: No module named _ssl
Check if openssl and openssl-devel are installed
[xxx@xxx ~]# rpm -aq|grep openssl openssl-x.x.xe-x.xxx openssl-devel-xxx-xxx
If you don't have these two packages, install them honestly.
[root@localhost ~]# yum install openssl-devel -y
This is the code to install, but I still get the error, oh my gosh
This is the yum command for linux. It uses python as the command interpreter. We upgraded python from the 2 that comes with linux to 3.
Solution:
a. Upgrade yum, forget it, a search is too troublesome
b. Find usr/bin/yum, open and change the first line "#!/usr/bin/python" to "#!/usr/bin/python2.6". 2.6 is the version that comes with my linux
The next step is to install the above missing packages openssl and openssl-devel again
3. Recompile python (reload)
Some need to change vi /usr/software/Python-3.6.3/Modules/Setup but I didn't find it, and finally it works
Socket module helper for socket(2) _socket socketmodule.c timemodule.c Socket module helper for SSL support; you must comment out the other socket line above, and possibly edit the SSL variable: SSL=/usr/local/ssl _ssl _ssl.c \ -DUSE_SSL -I$(SSL)/include -I$(SSL)/include/openssl \ -L$(SSL)/lib -lssl -lcrypto
then recompile
4. The next step is to execute python get-pip.py, of course, you can test step 2 again
After installation, use pip -V to report an error, as follows:
bash: pip: command not found...
What should I do at this time? ?
Just make a soft link:
first check the installation path:
find / -name pip
then make a soft link
ln -sv /usr/local/python/bin/pip /usr/bin/pip
and you can use it
5. The next step is simple
a. Install the virtual environment
pip install virtualenv
pip install virtualenvwrapper (extension package for managing virtual environments)
# Create a folder to hold the virtual environment
mkdir ~/Envs
sudo vi ~ / .bashrc
# Add the following two lines
export WORKON_HOME=~/Envs (if you don't write, there will be read and write permission problems)
source /usr/local/bin/virtualenvwrapper.sh
# run source ~/.bashrc
b. use
# new
mkvirtualenv -p (python version) name (the created virtual environment can be found in the path folder set above)
# choose
workon name
# delete
rmvirtualenv name
# quit
deactivate
Summary: The establishment of a virtual environment is very necessary, but improper operation of upgrading python can easily lead to version conflicts
As a result, various problems occur, which will affect the subsequent work, so we must pay attention.