python Virtual Environment Installation and Uninstallation Method and Problems Encountered

  • 2021-07-10 21:30:10
  • OfStack

Ubuntu16.04 Install and uninstall pip

Experimental environment

Ubuntu16.04; VMware15;

Problem description

The author installed Ubuntu16.04 on the virtual machine, and reopened it to compile python program after a period of time. When installing the required package, it was found that pip pip3 pointed to python2.7;;


hadoop@ubuntu:~$ pip3.5 -V
pip 19.1.1 from /usr/local/lib/python2.7/dist-packages/pip (python 2.7)
hadoop@ubuntu:~$ pip -V
pip 19.1.1 from /usr/local/lib/python2.7/dist-packages/pip (python 2.7)

Searching online and searching through various tutorials still can't make pip3 link to python3. The final solution to the problem is an accidental result after consuming time.

Problem solving

The solutions mentioned most in online tutorials are:

Installing pip

sudo apt-get install python3-pip

Upgrade pip

sudo pip3 install --upgrade pip

Uninstall

sudo apt-get remove python3-pip

1 This is the default pip3 points to python3, but it does not solve my problem. You can try. Maybe you can solve your problem. If you can't, look down.

The real solution to my problem:

Installing pip3

Install with the following statement. If you want to configure pip3 for the system's own python3.5, just execute curl https://bootstrap.pypa.io/get-pip.py sudo python3.6. After execution, if pip points to python3.5;; We only need to execute curl https://bootstrap.pypa.io/get-pip.py sudo python2.7 again.


#  Check and install python3.6
sudo apt-get update
sudo apt-get install python3.6
curl https://bootstrap.pypa.io/get-pip.py | sudo python3.6

Verify the pip version after completion:


hadoop@ubuntu:~$ pip3.5 -V
pip 19.1.1 from /usr/local/lib/python3.5/dist-packages/pip (python 3.5)
hadoop@ubuntu:~$ pip -V
pip 19.1.1 from /usr/local/lib/python2.7/dist-packages/pip (python 2.7)

It took me a long time to record the little problems at 1 o'clock.

To avoid some anomalies, it is recommended not to modify the python environment of the system

Summarize

Above is this site to introduce the python virtual environment installation and uninstallation methods and encountered problems, I hope to help you!


Related articles: