How do I activate my virtual environment using PyCharm? Can I even activate it in PyCharm?

I have am slightly confused about the local and command prompt in the terminal section of PyCharm. Could someone explain to me what the differences are?

Also, how do i activate my virtual environment from PyCharm, as i need it to run selenium (i placed it in a separate virtual environment). Do I use command prompt or local. I tried using local and when i type activate.bat in my Scripts folder, I come across this error message:

activate.bat : The term 'activate.bat' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. At line:1 char:1

  • activate.bat
  •   + CategoryInfo          : ObjectNotFound: (activate.bat:String) [], CommandNotFoundException
      + FullyQualifiedErrorId : CommandNotFoundException

Suggestion [3,General]: The command activate.bat was not found, but does exist in the current location. Windows PowerShell does not load commands from the current location by default. If you trust this command, instead type: ".\activat e.bat". See "get-help about_Command_Precedence" for more details. PS C:\Users\Jonathan\venvs\automation\Scripts>

Can someone assist me on how i can activate my virtual enviornment via PyCharm?

1 answer

  • answered 2021-10-24 15:13 alielbashir

    Yes, you can activate your virtual environment in Pycharm. Pycharm configures an interpreter for each project, and by default uses the system Python interpreter if not otherwise specified. To use the virtual environment's interpreter do the following:

    1. Settings > Project > Python Interpreter
    2. Click on the cog next to the path, and select Add... to add a new interpreter
    3. Select existing environment, and enter the path of the venv
    4. Click OK

    After doing this Pycharm will do some indexing, and the next time you run your program it should run using that virtual environment.

How many English words
do you know?
Test your English vocabulary size, and measure
how many words do you know
Online Test
Powered by Examplum