Python virtual environment installation and uninstallation methods and problems encountered

Python virtual environment installation and uninstallation methods and problems encountered

Ubuntu16.04 install and uninstall pip

Experimental environment

Ubuntu 16.04; VMware 15;

Problem Description

I installed Ubuntu 16.04 on a virtual machine. After a while, I reopened it and prepared to compile a python program. When installing the required packages, I found that pip pip3 all pointed to python 2.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)

After searching online and reading various tutorials, I still cannot get pip3 to link to python3. The final solution to the problem was an accidental result after spending time.

Problem Solving

The solution most often mentioned in online tutorials is:

Install pip

sudo apt-get install python3-pip

Upgrade pip

sudo pip3 install --upgrade pip

uninstall

sudo apt-get remove python3-pip

Generally, this will default pip3 to python3, but it doesn't solve my problem. You can try it, maybe it can solve your problem. If not, read on.

What actually solved my problem:

Install pip3

Use the following statement to install. If you want to configure pip3 for the system's built-in 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

After finishing, verify the pip version:

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 was just a small problem, but it took me a long time to record it.

To avoid some exceptions, it is recommended not to modify the system's built-in Python environment

Summarize

The above is the Python virtual environment installation and uninstallation method and problems encountered introduced by the editor. I hope it will be helpful to everyone!

You may also be interested in:
  • How to install Python3 and create a virtual environment under CentOS
  • Detailed tutorial on installing Python 3.6 environment and configuring virtual environment on centos
  • Detailed tutorial on installing virtualenv virtual environment in Python
  • Python installation virtualenv virtual environment steps detailed graphic instructions
  • Centos installation and configuration of Python virtual environment

<<:  In-depth understanding of MySQL global locks and table locks

>>:  Basic Implementation of AOP Programming in JavaScript

Recommend

Detailed explanation of nginx optimization in high concurrency scenarios

In daily operation and maintenance work, nginx se...

Node.js+express message board function implementation example

Table of contents Message Board Required librarie...

How to add a column to a large MySQL table

The question is referenced from: https://www.zhih...

Quickly get started with VUE 3 teleport components and usage syntax

Table of contents 1. Introduction to teleport 1.1...

Solution to EF (Entity Framework) inserting or updating data errors

Error message: Store update, insert, or delete st...

Linux yum package management method

Introduction yum (Yellow dog Updater, Modified) i...

Usage and description of HTML tag tbody

The tbody element should be used in conjunction wi...

border-radius method to add rounded borders to elements

border-radius:10px; /* All corners are rounded wi...

Continuous delivery using Jenkins and Docker under Docker

1. What is Continuous Delivery The software produ...

A brief discussion on the font settings in web pages

Setting the font for the entire site has always b...

HTML end tag issue and w3c standard

According to the principles of W3C, each start tag...

MySQL green version setting code and 1067 error details

MySQL green version setting code, and 1067 error ...

Summary of the application of transition components in Vue projects

​Transtion in vue is an animation transition enca...

Two ways to configure Vue global methods

Table of contents 1. Introduction 2. The first me...