Whenever I try to run script via Virtualenv in pycharm, i get this error:
C:UsersCostelloPycharmProjectstestvenvScriptspython.exe C:/Users/Costello/PycharmProjects/test C:UsersCostelloPycharmProjectstestvenvScriptspython.exe: can't find '__main__' module in 'C:/Users/Costello/PycharmProjects/test'
Everything works fine via idle, or vs code.
I figure it must be something with a way that I have setup my pycharm but have no idea what.
edit: this happens whatever I run, even simple print function.
edit: even with choosing regular python intepreteur, same happens just in pycharm
C:UsersCostelloAppDataLocalProgramsPythonPython37python.exe: can't find '__main__' module in 'C:/Users/Costello/PycharmProjects/test'
Figured out whats wrong. In the configuration window in pycharm, I had to select proper script path:
In your Pycharm:
Run - Edit Configurations
Configuration tabs, select
Module namein option
Choose target to runand type your python file’s name
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.
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.
Go to “Edit Configuration” and only speciy your filename like
Existing path —–>
Try with this —–>
I encountered this problem when my
cmd was forced to “End Task” by “Task Manager”. My problem solved when I restart my IDE.
“Open ‘Edit Run/Debug configurations’ dialog” (on the top, next to “Run”)
“script path:” –> select correct script path.
In Pycharm (Ubuntu):
- Create New Project
- Give Project Name
- Right Click on bin folder
- Create New Python File
- Write Your Code
- Upper Right Side: Add Configuration
- Left side: right click on “+” sign
- Input full file name
- Home/Downloads/myfile.py as “Script path”
- python 2.x/3.x as Python Interpreter
- Click on apply / ok