如何在Ubuntu的Spyder内部设置路径变量? [英] How to set path variable inside Spyder on Ubuntu?

查看:246
本文介绍了如何在Ubuntu的Spyder内部设置路径变量?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的软件包要求我将以下行添加到我的bashrc

I am using a package that requires me to add the following line to my bashrc

export PATH=${PATH}:~/cozmo/plataform-tools

当我从命令行调用python3或ipython3时,它可以完美工作.但是,当我通过双击Nautilus中的python文件启动Spyder时,它无法找到并执行该文件夹中的必需文件.所以,我的问题是

It works perfectly when I call python3 or ipython3 from the command line. However, when I start Spyder by double clicking a python file in Nautilus, it cannot find and execute a required file that is inside that folder. So, my question is

如何使spyder控制台使用在我的bashr中设置的PATH?还是如何在spyder中设置路径?

How to make the spyder console to use the PATH set at my bashr? Or how to set the path inside spyder?

我知道为什么在我启动Spyder时在命令提示符下设置的环境变量无效?,但是不能解决我的问题,因为我需要从Nautilus调用它(而不使用sudo),并且我不想在所有程序中添加声明路径的行.

I am aware of Why do the environment variables set in command prompt have no effect when I start Spyder, but it don't solve my problem, since I need to call it from Nautilus (and not use sudo) and I do not want to add a line declaring the path in all my programs.

推荐答案

我找到了在ipython控制台中设置变量的解决方案.只需包含

I found a solution to setting a variable in ipython console. Just include

import os, os.environ['PATH']+=':/home/bernardo/cozmo/platform-tools

在工具→中偏好→ iPython控制台→启动→线.我相信,如果使用Python控制台代替iPython控制台,则可以应用类似的解决方案.

in Tools → Preference → iPython console → Startup → Lines. I believe a similar solution can be applied if Python console is being used instead of iPython console.

通过这样做,即使没有从终端启动spyder,我也可以使用需要此路径的软件包.

By doing this I am able to use the package that requires this path even when spyder is not started from the terminal.

这篇关于如何在Ubuntu的Spyder内部设置路径变量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆