PyCharm current working directory

前端 未结 8 1369

Recently, I\'m unable to use relative paths in my code while using PyCharm. For instance, a simple open(\'test.txt\', \'r\') will not work - whereupon I am sure

相关标签:
8条回答
  • 2020-11-28 08:46

    I have Pycharm 4.5, so things might have changed a bit.

    Try going to Settings > Project > Project Structure

    On this dialog, click your folder that has the source code in it, and then click the blue folder in the menu to note it as "source" folder. I believe this fixes a lot of the path issues in Pycharm

    Here is the link to "content roots": https://www.jetbrains.com/pycharm/help/content-root.html

    0 讨论(0)
  • 2020-11-28 08:52

    Change: Run > Edit Configurations > Working directory, which sets the working directory for a specific project. (This is on a Mac)

    0 讨论(0)
提交回复
热议问题