如何在 Linux 上的 Spyder 中设置路径变量? [英] How to set path variable inside Spyder on Linux?

查看:108
本文介绍了如何在 Linux 上的 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.

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

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