Article directory
1.Problem description and solution
- When creating or opening a project in PyCharm, we need to select a python interpreter. If we choose to create a new virtual environment, as shown in the figure below:
- After entering the project, we open the terminal and see that we have automatically entered the virtual environment:
- However, if we try to use the pip command, an error will be reported , as shown in the figure:
- At this time, we only need to delete the folder in the picture :
- Then try using the pip command again:
- You can see that pip can be used normally!
- Since I inherited the global site, I have a lot of packages here
2. Use of virtual environment
2.1 Features
- Installing packages in a virtual environment does not affect global packages at all
- Virtual environments are free to use global packages as long as they choose to inherit the global site
- As shown in the picture, I installed scipy in the virtual environment, but this package is not available globally:
2.2 Entry and exit
Enter
<project-path>/venv/Scripts/activate
quit
<project-path>/venv/Scripts/deactivate