python path in pycharm terminal in a project setup with venv.

Hi,

I have created a project with venv in pycharm community edition 2018.1. The interepreter path is below:

D:\Py_projects\robotfw\venv\Scripts\python.exe

From pycharm terminal I have installed robot framework using "pip" from below path (starting path of terminal).

(venv) D:\Py_projects\robotfw>

Now when I want to launch "python ride.py" from same path , its throwing below error:

(venv) D:\Py_projects\robotfw>python ride.py
C:\python37\python.exe: can't open file 'ride.py': [Errno 2] No such file or directory

When I launch it from venv interpreter path as below it works.

(venv) D:\Py_projects\robotfw\venv\Scripts>python ride.py

Thats because ride.py is not installed in default python environment. I want to know why python in pycharm venv project terminal is taking the default system python interpreter instead of the venv python interpreter. How can we configure python and pip command to take venv paths when you run from terminal in venv project.

 

 

 

 

3 comments
Comment actions Permalink

Hello, 

 

First of all, please update the IDE to the latest version which is 2020.2 and see if it works there.  

 

If it is not, please:

1. attach a screenshot of Terminal settings

2. 'where python' command output

3. activate the venv out of PyCharm and run the script from the same location as "(venv) D:\Py_projects\robotfw>python ride.py" will it work? 

 

1
Comment actions Permalink

Hi,

I have no plans of upgrading now. Here are the attachments.

1. Terminal settings from pycharm. It works only when I keep the start directory as "D:\Py_projects\robotfw\venv\Scripts\"

 

2. (venv) D:\Py_projects\robotfw>where python
D:\Py_projects\django02sep\venv\Scripts\python.exe
D:\Py_projects\robotfw\venv\Scripts\python.exe
C:\python37\python.exe

 

3.activate the venv out of PyCharm and run the script from the same location as "(venv) D:\Py_projects\robotfw>python ride.py" will it work? 

No I did not work.

0
Comment actions Permalink

Hello,

Thank you for the screenshot. 

As you see, the error comes up out of PyCharm  it means the behaviour is venv/interpreter specific and not IDE related/caused. 

Please use other resources to find out a solution as I am afraid I am no longer able to assist you with it. 

0

Please sign in to leave a comment.