How to change the working directory for specific files

I want to do something unusual when it comes to python projects, but it has to be done.

In Spyder I dont have to set a project folder and still can freely navigate through folder and files in the file explorer tab, also with a simple right-click in the file I can set the working directory of the python console to the file directory.

Navigate in Spyder

 

Set console working directory in Spyder

I would like to do something similar in PyCharm. Navigate freely in files and folders without having to define a project (or defining. Whatever works best in PyCharm) and be able to rapidly set the console working directory to any file I want manually or automatically .

3 comments
Comment actions Permalink

Hello, 

 

The working directory can be changed in the Python console settings, please see https://www.jetbrains.com/help/pycharm/console-python-console.html. 

Regarding the file browsing, the thing is that PyCharm indexes all files under the project root in order to provide a code completion, navigation etc. If you open a very large directory the IDE performance may suffer, as a possible workaround directories can be marked as excluded, see the details here  https://www.jetbrains.com/help/pycharm/configuring-project-structure.html 

 

0
Comment actions Permalink

Hello, Antonina. Thanks for your reply.

The first link, about the console, takes me to an Error 404. Instead, I went to https://www.jetbrains.com/help/pycharm/console-python-console.html.

I understood that I need to specify the working directory in the console settings. The thing is: What should I put there to always set the console to the file folder? Maybe a PyCharm variable like the "WORKING_DIR_AND_PYTHON_PATHS"? But which?

 

0
Comment actions Permalink

 Hello, 

 

Unfortunately there is no such option. 

 

Please submit a feature request at https://youtrack.jetbrains.com/issues/PY

Information on how to use YouTrack: https://intellij-support.jetbrains.com/hc/en-us/articles/207241135-How-to-follow-YouTrack-issues-and-receive-notifications

0

Please sign in to leave a comment.