Pycharm没有看到相对路径中的文件../

Fak*_*ame 8 python path relative-path filepath pycharm

我正在使用pycharm开发一个python项目.但是,问题是它拒绝加载相对路径包含的文件../.当我尝试

self.image = pygame.image.load("../resources/img/prey.png").convert_alpha()
Run Code Online (Sandbox Code Playgroud)

我明白了:

self.image = pygame.image.load("../resources/img/prey.png").convert_alpha()
pygame.error: Couldn't open ../resources/img/prey.png
Run Code Online (Sandbox Code Playgroud)

问题是当从终端运行我的代码时,它工作正常,这意味着问题在于pycharm.

现在,问题是,虽然这听起来像许多其他问题,其中目录不是工作目录的一部分,添加:

import os
print os.getcwd()
Run Code Online (Sandbox Code Playgroud)

来自pycharm给了我 /media/Storage/System and dev/Code/Cross Platform/python/boids/current

我的目录结构似乎是正确的:

./current
    ./resources
        ./img
            prey.png
    ./objects
        modules_that_I_import.py
    ./experiments
        code_that_I_actually_run.py
Run Code Online (Sandbox Code Playgroud)

运行的代码self.image=pygame.image.load("../resources/img/prey.png").convert_alpha()./objects

Pycharm Community Edition 2016.1.2在Linux Mint上使用Python 2.7.

任何帮助表示赞赏.

编辑

os.getcwd我从命令行运行时,我得到了/media/Storage/System and dev/Code/Cross Platform/python/boids/current/experiments

use*_*698 13

转到Run - Edit Configurations,选择您的配置

运行配置编辑

Working directory改为/media/Storage/System and dev/Code/Cross Platform/python/boids/current/experiments.

工作目录编辑