如何更改sys.path? [英] how to change sys.path?

查看:369
本文介绍了如何更改sys.path?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是sys.path中路径的python搜索模块吗?

如何手动更改它?

解决方案

Ju Hui写道:

是sys.path中路径的python搜索模块吗?


sys.path是Python解释器搜索的路径列表

模块,是的。

如何更改它manuallly?




手动 ? - )


你的意思是动态地,通过代码 ?如果是的话,它只是一个列表。您可以像对待任何其他列表一样修改它。


否则,您可能需要查看PYTHON_PATH环境变量。 />

-

bruno desthuilliers

python -c" print''@''。join([''。''' .join([w [:: - 1] for p in p.split(''。'')])for

p in''o****@xiludom.gro''。 split(''@'')])"


是的,我的意思是我要更改sys.path值并将其保存到下一个

使用。

我可以更改sys.path的值,但我不能保存它是永久性的。

我的电脑上没有python_path环境,它与sys.path之间的关系是什么?



Ju Hui写道:

是的,我的意思是我要更改sys.path值并将其保存到下一个
使用。
我可以更改sys.path的值,但我不能保存永久。
我的电脑上没有python_path环境,它和sys.path之间的关系是什么?




在Windows中,至少,您可以创建PYTHONPATH变量并为其分配

,这是您希望Python在运行脚本时检查的目录的路径。


is python search module by paths in sys.path?
how to change it manuallly?

解决方案

Ju Hui wrote:

is python search module by paths in sys.path?
sys.path is the list of path where the Python interpreter will search
modules, yes.
how to change it manuallly?



"manually" ?-)

You mean "dynamically, by code" ? If yes, it''s just a list. You can
modify it like you''d do for any other list.

Else, you may want to look at the PYTHON_PATH environnement variable.

--
bruno desthuilliers
python -c "print ''@''.join([''.''.join([w[::-1] for w in p.split(''.'')]) for
p in ''o****@xiludom.gro''.split(''@'')])"


yes, I mean I want change the sys.path value and save it for next
using.
I can change the value of sys.path, but I can''t "save" it permanently.
There is no python_path environment on my pc, what the relationship
between it and the sys.path?


Ju Hui wrote:

yes, I mean I want change the sys.path value and save it for next
using.
I can change the value of sys.path, but I can''t "save" it permanently.
There is no python_path environment on my pc, what the relationship
between it and the sys.path?



In Windows, at least, you can create the PYTHONPATH variable and assign
to it the paths of the directories you want Python to check for when
running a script.


这篇关于如何更改sys.path?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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