purpose:
- Make the Python in anaconda and the native python3 of the official website coexist.
- Avoid package confusion and version conflicts in the project.
- Creating a separate virtual environment for each program can ensure that the program can access the packages in the virtual environment and keep the interpreter environment clean and tidy.
step:
1. Python installation under Windows
The reference link is as follows (written by a big guy): https://blog.csdn.net/nmjuzi/article/details/79075736
2. Install and use virtualenv
2.1 Install virtualenv
pip install virtualenv
Check whether the installation is successful:virtualenv --version
2.2 Create a virtual environment
Refer to the link: https://blog.csdn.net/weixin_43681088/article/details/106164708
- Here you can specify the command of the virtual environment path: (If you don’t specify the path, it’s usually on the C drive, so you can change it to your personal preference)
virtualenv D:\Users\Administrator\PyVirtualEnv\pylibrary
- You can also use python3 to create
rules: virtualenv -p (python3 installation path) (virtual environment name)
virtualenv -p d:/app/Python36/python.exe py36env
- The virtual environment has been created, we need to activate this environment, run the activate program under the pylibrary\Scripts\ directory to activate it:
activate
When there is more (pylibrary) in front of the command prompt, it means that we have successfully activated the virtual environment.