This is a memo of how to load a virtual environment with PyCharm (repeated).
--Hereafter, assume that the virtual environment name is'hoge'
--PyCharm is installed
--You have already created a virtual environment with virtualenv and it is ready to be called with `work on hoge`
.
cdvirtualenv
Let's execute the command in the virtual environment and check the directory where the virtual environment is saved.(I didn't know this and it took a lot of time)
# a.Start the virtual environment
$ workon hoge
# b.Change to the virtual environment directory
(hoge)$ cdvirtualenv
# c.Check the directory name
(hoge)$pwd
##In the case of the author, "C:\Users\me\Envs\"hoge" was displayed.
# d.Get the Python directory
(hoge)$ where python
##I think there will be two or more virtual and non-virtual environments. Step c.Find and copy the path that is in the same directory as.
## C:\Users\me\Envs\hoge\Scripts\python.exe (Copy this in this case)
## C:\Python\Python38\python.exe (This is for a non-virtual environment)
--a. When setting a virtual environment for a project that already exists -(1) With the project open, press Ctrl + Alt + s (or "File-> Settings ..." at the top of the screen) -(2) Enter "Project Interpreter". Display it on the screen, and the gear on the upper right-> Add -(3) Select Existing Environment in "Virtual env Environment" and paste the python file directory of the previous chapter 1-d into the Interpreter field. -(4) Press OK to create a virtual environment --b. If you want to set up a virtual environment when creating a new project -(1) New Project-> Open the screen "Project Interpreter: New Virtualenv environment" that appears. -(2) Paste the directory of the project you want to open in Location, and paste the directory of the python file in the previous chapter 1-d into Base Interpreter. -(3) Press create to complete the creation
that's all!
――I hope it helps beginners like you!
Recommended Posts