@Nadavb: indeed. If I'm not mistaken the latest dev version supports running Python modules properly. Hopefully they will also support running pkg_resources entry points from setup.py...
SOLVED. I had to add PYTHONPATH in the environment variables of the Pycharm. For some reason, I didn't have to have it during Run, but for Debug it's apparently crucial.
Yeah and it only took 4 years for that to finally happen. 4 years for a “mature”, non-free Python IDE to be able to run Python modules instead of scripts, which is actually how Python code is supposed to be run. This is intriguing, I honestly wonder why they didn’t solve this back in 2014. I switched to another IDE btw, there are several good choices nowadays.
no there is no better way now. You can file a feature request in our tracker.
Readers: vote for better support for this on the tracker at: https://youtrack.jetbrains.com/issue/PY-2784
Vote all you like, or just use my solution: https://github.com/amnong/misc/tree/master/pycharm_runner
Much love,
Amnon
It works for running, but debugging doesn't stop on any breakpoints :(
@Nadavb: indeed. If I'm not mistaken the latest dev version supports running Python modules properly. Hopefully they will also support running pkg_resources entry points from setup.py...
I have PyCharm 2017.3.2.
I can run a module, but when I do debug it writes: "No module named ..." Do you know what's the solution?
SOLVED. I had to add PYTHONPATH in the environment variables of the Pycharm. For some reason, I didn't have to have it during Run, but for Debug it's apparently crucial.
This now is supported by PyCharm!
When you create your `Run`, under the Configuration tab you'll notice a carrot next to `Script path:`
Click on it and select "Module name". Then you can set any args on the Parameters line...and no, you don't need to include `-m` anywhere :)
(I found the answer to this problem in this SO thread.)
Yeah and it only took 4 years for that to finally happen. 4 years for a “mature”, non-free Python IDE to be able to run Python modules instead of scripts, which is actually how Python code is supposed to be run. This is intriguing, I honestly wonder why they didn’t solve this back in 2014. I switched to another IDE btw, there are several good choices nowadays.