Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

application runs from pycharm but not from command line (ModuleNotfounderror)

I have app with the following folder tree:

MyApp
  |
  |-- Code
  |     |
  |     |-- main.py
  |     |-- settings.py
  |     |
  |-- vev

venv – is the virtual environment of that project.

I can run main.py from pycharm without any problem.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

I’m trying to run it from command line:

  1. I activate the venv

  2. I run the following command from MyApp folder:

    python Code\main.py

and I’m getting the following error:

ModuleNotFoundError: No module named 'Code'

How can I run main.py from command line (without any code change if it possible)

>Solution :

It happens because pycharm usually sets PYTHONPATH for you.
To manually execute your code you need to set new PYTHONPATH variable.

On linux/mac it should be:
export PYTHONPATH=$(pwd)

And after this you should be able to run your code

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading