Configuring the working directory in Eclipse 3.8.1 with PyDev-project

不羁岁月 提交于 2019-12-12 03:34:09

问题


I'm trying run a python script in Eclipse 3.8.1 but I keep getting the error message:

IOError: [Errno 2] No such file or directory 

The problem occurs in a code line:

train_labels = np.loadtxt("./examples/data/class_train.labels")

Here is a screenshot of my project:

It seems the relative path starts from the location of the script itself, whereas I would want the relative path start from the root directory of the project, that is the RLScore-folder as you can see in the image.

How do I configure this?

P.S. I wouldn't want to edit the code, because this is not my own code and I would need to do the editing into many other files in the distribution.


回答1:


try :

train_labels = np.loadtxt("../data/class_train.labels")


来源:https://stackoverflow.com/questions/30504829/configuring-the-working-directory-in-eclipse-3-8-1-with-pydev-project

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!