Skip to content Skip to sidebar Skip to footer

Pycharm Gets Error "can't Find '__main__' Module"

Whenever I try to run script via Virtualenv in pycharm, i get this error: C:\Users\Costello\PycharmProjects\test\venv\Scripts\python.exe C:/Users/Costello/PycharmProjects/test C:\U

Solution 1:

Figured out whats wrong. In the configuration window in pycharm, I had to select proper script path:

enter image description here


Solution 2:

In your Pycharm:

  1. Select Run - Edit Configurations
  2. In Configuration tabs, select Module name in option Choose target to run and type your python file's name
  3. Click Apply and OK button

Or the simple way is when you run your code for first time (on a new file) just type keyboard Alt+Shift+F10 to run and save the configuration. On the second time (after configuration is saved) just type Alt+F10 to run your code.


Solution 3:

Go to "Edit Configuration" and only speciy your filename like filename.py

Existing path -----> C:\Users\np4\PycharmProjects\TEST\venv

Try with this -----> C:\Users\np4\PycharmProjects\TEST\venv\MultiSites.py


Solution 4:

"Open 'Edit Run/Debug configurations' dialog" (on the top, next to "Run") "Edit Configurations" "script path:" --> select correct script path.


Solution 5:

I fixed it by removing values from Interpreter options field in run/debug configurations. While trying to add an interpreter, I had added the python path to the mentioned field.

After clearing out the field all worked well.

You can find run/debug configuration settings in the drop-down left of run icon on top-right of pycharm window.


Post a Comment for "Pycharm Gets Error "can't Find '__main__' Module""