简体   繁体   English

Pydev相对项目路径

[英]Pydev relative project path

I installed eclipse with pydev plugin. 我用pydev插件安装了eclipse。 I need to run my existing project on eclipse. 我需要在eclipse上运行我现有的项目。 But there are relative paths to the files inside my code. 但是我的代码中有文件的相对路径。 I expect from eclipse to append relative paths to the project's default directory. 我期望从eclipse将相对路径附加到项目的默认目录。 Instead, it appends the relative path to the directory where Eclipse is installed. 相反,它会将相对路径附加到安装Eclipse的目录。 I could not find a way to solve the problem. 我找不到解决问题的方法。

Thanks in advance. 提前致谢。

I finally found out how to do it and I am writing the answer for other people with the same problem. 我终于找到了如何做到这一点,我正在为有同样问题的其他人写答案。 You can find it in Run Configurations or Debug Configurations. 您可以在“运行配置”或“调试配置”中找到它。 Choose "Python Run" and your run configuration from the left and then in the "Arguments" tab in the right side, set your "working directory" as "other" with giving "the path" on which you want to run your code. 从左侧选择“Python Run”和您的运行配置,然后在右侧的“Arguments”选项卡中,将“工作目录”设置为“其他”,并提供要运行代码的“路径”。 Thanks for your interest, Wayne btw. 感谢您的关注,Wayne btw。

Take a look in the project settings, I've never used Pydev with Eclipse, but you should be able to set where the project is executed at, or paths for references. 看看项目设置,我从未在Eclipse中使用过Pydev,但您应该能够设置项目执行的位置或引用路径。

Of course there may be a better solution, but hopefully that's some help! 当然可能有更好的解决方案,但希望这有一些帮助!

Another way to do it is to go to the 'Environment' tab from the "Run Configuration". 另一种方法是从“运行配置”转到“环境”选项卡。 Add a new variable with name, "PATH", specifying your desired directory in the "Value" box. 添加名为“PATH”的新变量,在“值”框中指定所需的目录。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM