如何永久添加到Pythons sys.path?

编程入门 行业动态 更新时间:2024-10-27 09:42:00
本文介绍了如何永久添加到Pythons sys.path?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

>> sys.path [''C:\\Python25 \\Progs \\NatLangProc'',''C:\\Python25 \\Lib \\idlelib'',''C:\ \ Windows \\ system32 \\python25.zip'',''C:\\ \\\Python25 \\lib \\site-packages \ \ range'',''C:\\Python25 \\lib \\ site-packages \\\\\ OrangeWidgets'', ''C:\\Python25 \\lib \\site-packages \\\\ \\OrangeCanvas'',''C:\ \Python25 \\DLLs'',''C:\\Python25 \\lib'', ''C:\\Python25 \\lib \\plat-win'', ''C:\\Python25 \\lib\\\ lib-tk'',''C:\\Python25'',''C:\\Python25 \\lib\\site- pac kages'',''C:\\Python25 \\lib\\site-packages \\Numeric'',''C:\\Python25 \ \lib\\site-packages \\PIL'']

>>>

现在我的个人程序在C:/ Python25 / Progs / 如何添加以便我可以导入一些文件从任何地方 解释器中的该目录,它可以从该目录中的其他 文件夹加载文件。

解决方案

2008年10月16日17:13,cnb写道:

>>> sys.path

[''C:\\Python25 \\ \\\Progs \\NatLangProc'',''C:\\Python25 \\Lib \\idlelib'', ''C:\ \ Windows \\system32 \\python25.zip'',''C:\\Python25 \\lib \\site-packages \ \ range'',''C:\\Python25 \\lib \\site-packages \\\\\ OrangeWidgets'', ''C:\\Python25 \\lib \\site-packages \\\\\ OrangeCanvas'',''C:\ \Python25 \\DLLs'',''C:\\Python25 \\lib'',''C: \\Python25 \\lib \\plat-win'', ''C:\\Python25 \\lib \\lib-tk' ',''C:\\Python25'',''C:\\Python25 \\lib\\site- 包'',''C: \\Python25 \\lib \\site-packages \\Numeric'',''C:\\Python25 \ \lib \\\ \\ site-packages \\PIL'']

>>>>

现在我的个人程序在C:/ Python25 / Progs / 如何添加所以我可以做导入一些文件在任何地方 解释器中的目录,它可以从该目录中的其他 文件夹加载文件。 - mail.python/mailman/listinfo/python-清单

a临时解决方案是将其附加到该列表: sys.path .append(''C:/ Python25 / Progs /'') a永久解决方案是将它添加到环境变量 (不知道在哪里在windows中设置这个)

PYTHONPATH =" / C:/ Python25 / Progs /" gr Arno

9月16日,5:25 * pm,Python< pyt ... @ rgbaz.euwrote:

2008年10月16日17:13,cnb写道:

>> sys.path

[''C:\\Python25 \\Progs \\NatLangProc'',''C:\\Python25 \\Lib\\IDLElib'',* ''C:\ \ Windows \\ system32 \\python25.zip'',''C:\\Python25 \\ lib \\site-packages \ \ range'',''C:\\Python25 \\lib \\site-packages \\\ \\\OrangeWidgets'', ''C:\\Python25 \\lib\\site-packages \\\\\OrangeCanvas'',' 'C:\ \Python25 \\DLLs'',''C:\\Python25 \\lib'',''C:\\Python25 \\lib \\plat-win'', ''C:\\Python25 \\lib \\lib-tk'',''C :\\Python25'',''C:\\Python25 \\lib\\site- packages' ,''C:\\Python25 \\lib \\site-packages \\Numeric'',''C:\\Python25 \ \\ \\ lib\\site-packages \\PIL'']

现在我的个人程序在C:/ Python25 / Progs /

如何添加以便我可以执行import somefile在任何地方 解释器中的目录,它可以从该目录中的其他 文件夹加载文件。 - mail.python/mailman/listinfo/python-清单

a临时解决方案是将其附加到该列表: sys.path.append(''C:/ Python25 / Progs /'') a永久解决方案是将它添加到环境变量 (不知道在windows中设置此位置)

>>sys.path [''C:\\Python25\\Progs\\NatLangProc'', ''C:\\Python25\\Lib\\idlelib'', ''C:\ \Windows\\system32\\python25.zip'', ''C:\\Python25\\lib\\site-packages\ \orange'', ''C:\\Python25\\lib\\site-packages\\orange\\OrangeWidgets'', ''C:\\Python25\\lib\\site-packages\\orange\\OrangeCanvas'', ''C:\ \Python25\\DLLs'', ''C:\\Python25\\lib'', ''C:\\Python25\\lib\\plat-win'', ''C:\\Python25\\lib\\lib-tk'', ''C:\\Python25'', ''C:\\Python25\\lib\\site- packages'', ''C:\\Python25\\lib\\site-packages\\Numeric'', ''C:\\Python25\ \lib\\site-packages\\PIL'']

>>>

Now I have my personal programs in C:/Python25/Progs/ How do I add so that I can just do "import somefile" from anywhere in that directory in the interpreter and it can load files from other folders in that directory.

解决方案

On 16 sep 2008, at 17:13, cnb wrote:

>>>sys.path

[''C:\\Python25\\Progs\\NatLangProc'', ''C:\\Python25\\Lib\\idlelib'', ''C:\ \Windows\\system32\\python25.zip'', ''C:\\Python25\\lib\\site-packages\ \orange'', ''C:\\Python25\\lib\\site-packages\\orange\\OrangeWidgets'', ''C:\\Python25\\lib\\site-packages\\orange\\OrangeCanvas'', ''C:\ \Python25\\DLLs'', ''C:\\Python25\\lib'', ''C:\\Python25\\lib\\plat-win'', ''C:\\Python25\\lib\\lib-tk'', ''C:\\Python25'', ''C:\\Python25\\lib\\site- packages'', ''C:\\Python25\\lib\\site-packages\\Numeric'', ''C:\\Python25\ \lib\\site-packages\\PIL'']

>>>>

Now I have my personal programs in C:/Python25/Progs/ How do I add so that I can just do "import somefile" from anywhere in that directory in the interpreter and it can load files from other folders in that directory. -- mail.python/mailman/listinfo/python-list

a temp solution is to append it to that list: sys.path.append(''C:/Python25/Progs/'') a permanent solution is to add it to the environment variable (no idea where to set this in windows)

PYTHONPATH = "/C:/Python25/Progs/" gr Arno

On Sep 16, 5:25*pm, Python <pyt...@rgbaz.euwrote:

On 16 sep 2008, at 17:13, cnb wrote:

>>sys.path

[''C:\\Python25\\Progs\\NatLangProc'', ''C:\\Python25\\Lib\\idlelib'', * ''C:\ \Windows\\system32\\python25.zip'', ''C:\\Python25\\lib\\site-packages\ \orange'', ''C:\\Python25\\lib\\site-packages\\orange\\OrangeWidgets'', ''C:\\Python25\\lib\\site-packages\\orange\\OrangeCanvas'', ''C:\ \Python25\\DLLs'', ''C:\\Python25\\lib'', ''C:\\Python25\\lib\\plat-win'', ''C:\\Python25\\lib\\lib-tk'', ''C:\\Python25'', ''C:\\Python25\\lib\\site- packages'', ''C:\\Python25\\lib\\site-packages\\Numeric'', ''C:\\Python25\ \lib\\site-packages\\PIL'']

Now I have my personal programs in C:/Python25/Progs/

How do I add so that I can just do "import somefile" from anywhere in that directory in the interpreter and it can load files from other folders in that directory. -- mail.python/mailman/listinfo/python-list

a temp solution is to append it to that list: sys.path.append(''C:/Python25/Progs/'') a permanent solution is to add it to the environment variable (no idea where to set this in windows)

更多推荐

如何永久添加到Pythons sys.path?

本文发布于:2023-05-31 10:08:49,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/389603.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:Pythons   sys   path

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!