1

I have a python project and I need to use its venv in the terminal offered by PyCharm. However, some dependencies show as not installed but they are present in the venv folder. I think the project is using another venv in the Terminal. How can I check which venv is being used in the terminal and how can I change it to be the one in the project's folder?

Ian Kurtis
  • 137
  • 7
  • You can test with `which python` on Linux/MacOS or `where python` on windows in the terminal to identify what is the current interpreter and to locate what venv is used. if you want to change it you can go on PyCharm `file -> settings -> project interpreter` then select the correct python interpreter in your project folder – Romibuzi Oct 21 '21 at 08:57
  • @Romibuzi i tried the where command but nothing showed up. – Ian Kurtis Oct 21 '21 at 09:03
  • Does this answer your question? [How do I activate a virtualenv inside PyCharm's terminal?](https://stackoverflow.com/questions/22288569/how-do-i-activate-a-virtualenv-inside-pycharms-terminal) – bad_coder Oct 21 '21 at 10:59

1 Answers1

0

If you execute any program using 'run' button in PyCharm, it will give you the python it is using, in your case, it should be venv. Now from Terminal use that command instead on just python/python3. For example, your are running a program using run button, you would see something like

/Users/soumyabratakole/.local/share/virtualenvs/pythonProject-8Ymrt2w6/bin/python /Users/soumyabratakole/PycharmProjects/pythonProject/main.py

Now you can use /Users/soumyabratakole/.local/share/virtualenvs/pythonProject-8Ymrt2w6/bin/python instead of just python from your terminal to use your venv.

soumya-kole
  • 1,111
  • 7
  • 18
  • Is there any other way to set the venv to the terminal and just use it for pytests and everything? -instead of copying the path all the time – Ian Kurtis Oct 21 '21 at 09:02
  • of course, actually venv helps you to create similar environments on different computers. You need create a requirements.txt in your current setup. Then you can create another virtual environment and get required package in new venv using requirements.txt . More information can be found in https://stackoverflow.com/questions/9207430/how-to-copy-clone-a-virtual-environment-from-server-to-local-machine – soumya-kole Oct 21 '21 at 09:18