Table of Contents
- PyCharm virtualenv configuration creating a new venv
- PyCharm virtualenv configuration import an existing venv
If you are working on a Python project, you will probably want to have a virtualenv configured.
This article will show you how to do a complete virtualenv configuration in Pycharm.
More in details there is two sections:
- How to create a new virtualenv from PyCharm
- How to import an existing virtualenv from PyCharm
Don’t know what a virtualenv is? Don’t worry, take two minutes and check this article.
PyCharm virtualenv configuration creating a new venv
Virtualenv configuration in PyCharm is very simple, you have just to follow these steps:
- Open PyCharm settings
- Click on ‘Project’ and then on ‘Python Interpreter’
- Click on the gear icon in the top right corner of the window and select ‘Add’ option
Clicking on ‘Add’ a new window will appear and it is possible to noticed a couple of things.
If you are going to create a standard virtualenv, like in this tutorial, choose ‘Virtualenv Environment’ from the menu on the left and the option ‘New environment’ in the middle of the window.
Now the only thing to do is to choose a location for your new virtual environment.
Be sure that the folder is empty!
Last but not least, choose a base interpreter that is the python version on which the virtual environment will be created.
By confirming the choices, the virtualenv will be created. Easy isn’t it?
PyCharm virtualenv configuration import an existing venv
The procedure to import an existing virtual environment is very easy and similar to the one used to add a new virtualenv.
If you have not already, read the procedure explained in the section above.
In this case, instead of choose ‘New environment’, click on the second option called ‘Existing environment’.
Now to get your virtualenv configured correctly you just need to specify the path.
But remember, it is essential to go all the way to the python file in order to be able to add it correctly!
Using these two procedure it is possible to create or add a virtualenv in PyCharm and use it in your project.
It is quite simple and straightforward, no?
Let me know in the comments if you any doubts or are in troubles!