问题
Pycharm's interpreter seems to have stopped understanding some of my console commands. It keeps recognizing default shell commands but doesn't recognize installed utilities.
For example, subprocess
module understands touch
command but doesn't understand heroku
command.
The funny thing is, when I enter the same string into the console, with the same interpreter (from the same virtualenv), everything works fine.
A visual example:
It stopped working a couple days ago, and before that everything had worked fine.
I thought I had messed up some of my env vars, but opened an old project I hadn't touched for a month, and saw that the same subprocess
commands stopped working there too.
What could be the problem?
UPDATE
Ok, I got this thing to work.
The values of os.environ['PATH']
were different in console and in Pycharm. After I added the correct PATH to the Pycharm configuration env vars, everything started working again.
Now the question is, how do I avoid going through each configuration in each and every of my projects and adding this new PATH everywhere? Is there a way to do this globally and repair this one only setting that's been broken?
回答1:
I see you figured out how to configure PyCharm's project PATH.
As for how to not have to do this for every project new project you start, you just have to update your default project configuration.
From Accessing Default Settings:
PyCharm helps define settings of a default project. These settings are used as defaults every time you create a new project.
To access default project settings
- On the main menu, choose File | Default Settings
- Define the desired settings in the Settings dialog box that opens.
Note: updates to the default project configurations only apply to future new projects, any existing project configuration needs to be updated manually.
来源:https://stackoverflow.com/questions/40724079/pycharm-and-subprocess-what-works-in-console-doesnt-work-in-pycharm