r/learnpython • u/Artistic-Army4423 • 8d ago
Virtual Environment and Python
I have started learning python and decided to use pycharm as an editor. I want to know anything which will help me in this journey.
My main question is => I don't get "virtual environment" thing with python. I cloned a repo and opened it in pycharm, it says "No python interpreter configured for <repo-name>" and then suggested to create virtual environment.
I want to hear things from experience devs.
thank you.
4
Upvotes
-1
u/OkCaterpillar1058 8d ago edited 8d ago
To activate a virtual environment you can do:
cd project
source venv/bin/activate
If you want to make your own virtual environment
python3 -m venv venv
Then whatever packages you install, are only installed in that virtual environment, not system wide. The reason you do this, is to avoid conflicting packages. One project may need A 1.0 while another needs A 1.1 on the same system.
In PyCharm to change the interpreter:
Press Ctrl + Alt + S to open settings and then select Python | All Interpreters.
Select the interpreter and click Edit Interpreter… on the toolbar.
In the Interpreter Settings dialog, change the interpreter name in the Interpreter Name field or modify the target settings. Then click Save.
If I remember right, in PyCharm when you start a new project, it makes a virtual environment automatically. But I haven't used it in a long time