How to call a preexistent Python script that runs under no specific virtual environment, from a Pycharm project which does use a venv



I have a working Pycharm project that uses a virtual environment. Now I need to run from this same project a preexistent Python script. 


For reference, this second script was created with gnuradio and works in Ubuntu 20.04 shell with no specific call to any virtual environment.  Actually, it should use the default /usr/bin/env.


I tried different approaches: For instance, If I call this script from shell as >> python3, it works fine. Also, if I create a dedicated Pycharm project and properly configure the interpreter and paths, this also works.


The issue is that, if I add those interpreter settings to the original Pycharm project, there is a conflict with the dependecies, as the original project should use a venv and the should use the default env.


I also tried using subprocess to call that, however the venv settings still seem to be an issue.


My experience is limited here. So I am not sure if my attempts were 100% correct. I would appreciate your help on how to solve this. 




Each time you run a program, it creates a Run Configuration that contains the information needed to setup running the program. See 

Would it work for you if you change the interpreter to the expected one only in the Run Cofiguration of the script in question?  Please give it a try. 



Hi Antonina! Thank you so much for your comment!


Based on your comment, I set a different run configuration for each module, so that each uses its own interpreter settings and its own folder paths settings. Then, I tried running each module separately using that config, and it works.


However, I need to call one module from the other. Then, when I import one module from the other, there is an ‘unknown location’ error for its dependencies (as I assume only one of the settings above for interpreter and paths is used).


Please let me know if I am missing something.




Hello Alfred, 

There is an option to define environment variables in Run Configurations. 

You may define PYTHONPATH variable which will refer to the module location. Please see


Please sign in to leave a comment.