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?
You can assign a shortcut to open Python console: press Ctrl+Alt+S , navigate to Keymap, specify a shortcut for Main menu | Tools | Python or Debug Console. The main reason for using the Python console within PyCharm is to benefit from the main IDE features, such as code completion, code analysis, and quick fixes.
To use a pipe with the subprocess module, you have to pass shell=True . In your particular case, however, the simple solution is to call subprocess. check_output(('ps', '-A')) and then str. find on the output.
In PyCharm terminal you can type 'cls' just like in linux terminal. You can also click somewhere on the PythonConsole -> Right button -> clear.
From the main menu, select File | Manage IDE Settings | Restore Default Settings. Alternatively, press Shift twice and type Restore default settings . Click Restore and Restart. The IDE will be restarted with the default configuration.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With