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

How to use mysql index merge

Index merging is an intelligent algorithm provide...

Summary of some tips for bypassing nodejs code execution

Table of contents 1. child_process 2. Command exe...

Basic commands for MySQL database operations

1. Create a database: create data data _name; Two...

A brief discussion on CSS blocking merging and other effects

Non-orthogonal margins When margin is used, it wi...

Solution for converting to inline styles in CSS (css-inline)

Talk about the scene Send Email Embedding HTML in...

Implementation steps of Mysql merge results and horizontal splicing fields

Preface Recently, I was working on a report funct...

Configure Mysql master-slave service implementation example

Configure Mysql master-slave service implementati...

Detailed explanation of the use of props in React's three major attributes

Table of contents Class Component Functional Comp...

How to disable ads in the terminal welcome message in Ubuntu Server

If you are using the latest Ubuntu Server version...

An example of how Tomcat manages Session

Learned ConcurrentHashMap but don’t know how to a...

Detailed explanation of MySQL delayed replication library method

Simply put, delayed replication is to set a fixed...

The easiest way to make a program run automatically at startup in Linux

I collected a lot of them, but all ended in failu...

How to open the port in Centos7

The default firewall of CentOS7 is not iptables, ...

Summary of Linux Logical Volume Management (LVM) usage

Managing disk space is an important daily task fo...