Change current working directory

已回答

Hello,

I have my folder project, with no assignation. Then, I want to add a content root, in "settings-project structure" for using some base code that I use in different projects. No matter if I assign this new folder as a source (blue folder) or no assignation, my current working directory is changed to this last folder path.

How I can avoid this?
How I can change the working directory? 

Thanks.

 

0

You can change the working directory in a run configuration Run | Edit Configurations...

Is that what you are looking for?

2
Avatar
Permanently deleted user

Ok. I think it might be a small bug. 


Bearing in mind your comment, if I run the x.py, y.py...or whatever file, it will appear in the list of edit configuration...at will work fine, and python console will work. But, if I create a x.py, and run a selection in python console (shift + alt + E), with no previous first run (ctrl+shift+F10) of the whole file, will give me the error comment in my first message, and will not appear in the list of edit configuration...

I understand its something I can change in setting/console/python console/starting script?:

import sys; print('Python %s on %s' % (sys.version, sys.platform))
sys.path.extend([WORKING_DIR_AND_PYTHON_PATHS])

 

0

What error do you get?
The presence/absence of a run configuration shouldn't matter when you execute selection since it just copies and runs the code in Python Console.
What is your PyCharm version?

0
Avatar
Permanently deleted user

Hi! Thanks for your quick answer.

The error, if its an error, is that when I run code in Python Console, the working directory that it uses, is the last folder I add to content root, in "settings-project structure".

I have changed to the working directory in "settings - console - python console - working directory" and seems to work, but I don't understand why it gets, (before the previous change I have mentioned) the last folder I add, independently that I change it in "run/debug configurations" or the assignation I give to the folder I add: "source, resource, etc..."

0

I can't reproduce it.

What are your OS and PyCharm version?

0
Avatar
Permanently deleted user

Windows 10. Pycharm 2020.1.

1) I create new project test with test1.py. cwd folder test

 

2) I add new folder with "settings - project structure - add content root"

3) 
Close and open PyCharm. I can load juan.calvo.transformations from 00_CODE_BASE but the cwd has change

0

Ah, I see now.
Thanks for the detailed description.

I filed a bug to our issue tracker https://youtrack.jetbrains.com/issue/PY-42447

0
Avatar
Permanently deleted user

A pleasure. Thanks for your great IDE. :) 

0

请先登录再写评论。