Add_VirtualEnvironment_GherkinPlugin_To_PyCharm

Tutorial 5​​ ​​ Add​​ Python​​ Virtual Env and Gherkin plugin to​​ PyCharm

Welcome to the 5th article in Behave BDD series!

What you will Learn :

  • Add Python virtual environment to​​ PyCharm IDE

  • Verify whether virtual env got successfully added or not

  • Add Gherkin Plugin to PyCharm

  • Verify whether Gherkin plugin got successfully added or not

  • Additional Note

Add​​ Python Virtual Environment to PyCharm IDE

We will​​ now see how to​​ add the Python virtual environment (that we had created in previous tutorials) to PyCharm IDE.​​ Before we do that, let us first activate the virtual environment that we had created. To do that, go to command line and execute below commands

Notice above that we see the virtual environment directory that we had created earlier venv_py3.

Execute below commands to activate the virtual environment

​​ 

Next execute ‘where python’ command, you will see the path of virtual environment

Copy the above path​​ 

In your PyCharm, go to File > Settings​​ 

The below window comes up

On the left hand panel, expand the project and select Python Interpreter, as seen above. The right hand side section shows all the packages/libraries installed for a particular python interpreter. At the moment, the Python Interpreter that you see on right hand​​ side is the default Python interpreter. As you can see, right now we don’t see ‘behave’ library that we had installed for our virtual environment.​​ 

To add our virtual env, click the gear icon that you see above

Click Add, the below window comes up

As seen above, select ‘Virtualenv Environment’ from the left hand side and select the radio button ‘Existing environment’ that you see on right hand side

Click​​ 

Paste the path that we had copied earlier: C:\Users\DELL\AppData\Local\Programs\Python\Python37-32\Scripts\venv_py3\Scripts\python.exe

Click Ok, the same path will become visible below

Click Ok, the same path will become visible below.​​ 

You can also see the behave and selenium packages that we had installed earlier for this virtual environment

In the command prompt, execute the below command, you will see that the version number matches  ​​​​ 

Click Ok​​ that yousee in the below window

We will come back to our project

Verify whether virtual env got successfully added or not

To verify, right click project > New >Python File

Enter any name.py

Hit Enter. The python file gets created

See below. We do see the recommendation for selenium library

Similarly

Similarly for behave

This is how you setup a custom virtual env in PyCharm.

Add Gherkin Plugin to PyCharm

We will​​ now​​ add the Gherkin Plugin to​​ our​​ PyCharm​​ IDE.

To do that, go to File > Settings > Plugins > Search for Gherkin, see below

Click Install, the plugin gets installed

Click Apply and Ok

Verify whether Gherkin plugin got successfully added or not

Right click project > New > File

Type some name.feature

Hit Enter

The green colored cucumber like icon that you see implies that Gherkin plugin is installed, see below

We also get Gherkin keyword auto-suggestions

Further, we see blue color Gherkin keywords

So this is how we add Gherkin plugin to PyCharm IDE

Additional Note

Note that you can go to File > Settings > Expand Editor > Select Font > Enter​​ desired font​​ and desired​​ size for your python code

After changing the size/font, click Apply/Ok

Thank you​​ for reading!

Share On

Share on facebook
Share on twitter
Share on linkedin
Share on whatsapp
Share on tumblr
Share on email

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top

Lifetime Membership Club

LIFETIME MEMBERSHIP BIG SALE - ALL LIVE COURES JUST - 7000 RS/ 99 USD
Attend All Live courses in just 7000 rs / $99 - offer ends 1st Nov 2024