本文介绍了如何永久添加到Pythons sys.path?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! >> 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 / 如何添加以便我可以导入一些文件从任何地方 解释器中的该目录,它可以从该目录中的其他 文件夹加载文件。 解决方案 [''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 / 如何添加所以我可以做导入一些文件在任何地方 解释器中的目录,它可以从该目录中的其他 文件夹加载文件。 - http://mail.python.org/mailman/listinfo/python-清单 a临时解决方案是将其附加到该列表: sys.path .append(''C:/ Python25 / Progs /'') a永久解决方案是将它添加到环境变量 (不知道在哪里在windows中设置这个) [''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''] 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 inthat directory in the interpreter and it can load files from otherfolders in that directory. 解决方案[''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 inthat directory in the interpreter and it can load files from otherfolders in that directory.-- http://mail.python.org/mailman/listinfo/python-lista 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) [''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'']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?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
06-13 22:24