Python:系统变量路径被更改,与sys.path中的值不匹配

时间:2015-12-17 07:22:28

标签: python import module path system-variable

我有一个脚本“splash.py”存储在C:\ Users \ cedwards \ saved_scripts

我已在变量“Path”(环境变量)中的系统变量中添加了此目录

当我在sys.path中打印所有值时,我得到..

>>> import sys
>>> for val in sys.path:
...     print val
... 

C:\Python27\lib\site-packages\openpyxl-2.3.2-py2.7.egg
C:\Python27\lib\site-packages\et_xmlfile-1.0.1-py2.7.egg
C:\Python27\lib\site-packages\jdcal-1.2-py2.7.egg
C:\Python27\Lib
*C:\Python27\Scripts\* C:\Python27\DLLs
*C:\Python27\Scripts\* C:\Python27\Lib\lib-tk
*C:\Python27\Scripts\* C:\Users\cedwards\saved_scripts
C:\WINDOWS\system32\python27.zip
C:\Python27\DLLs
C:\Python27\lib\plat-win
C:\Python27\lib\lib-tk
C:\Python27
C:\Python27\lib\site-packages
C:\Python27\lib\site-packages\win32
C:\Python27\lib\site-packages\win32\lib
C:\Python27\lib\site-packages\Pythonwin
C:\Python27\lib\site-packages\wx-2.8-msw-unicode
>>> 

斜体中的值不应该存在?我输入PATH的值是“C:\ Python27 \ lib \ site-packages \ openpyxl-2.3.2-py2.7.egg; C:\ Python27 \ lib \ site-packages \ et_xmlfile-1.0.1-py2。 7.egg; C:\ Python27 \ lib中\站点包\ jdcal-1.2-py2.7.egg; C:\ Python27 \库; C:\ Python27 \的DLL; C:\用户\ cedwards \ saved_scripts; C: \ WINDOWS \ SYSTEM32 \ python27.zip; C:\ Python27 \ LIB \高原共赢; C:\ Python27 \ LIB \ LIB-TK; C:\ Python27; C:\ Python27 \ LIB \站点包; C:\ Python27 \ LIB \站点包\ WIN32; C:\ Python27 \ LIB \站点包\ WIN32 \ lib中; C:\ Python27 \ LIB \站点包\ PythonWin的; C:\ Python27 \ LIB \站点包\ WX -2.8-MSW-unicode的“

Obvioulsy,当我尝试在新脚本中导入splash时,它不起作用。

我的问题是,为什么* C:\ Python27 \ Scripts *重复?我认为这是阻止我的模块导入的原因。

1 个答案:

答案 0 :(得分:0)

我添加了一个名为PYTHONPATH的用户变量,其中包含我原始问题中所述的值,并且可以正常工作。

我不应该将它添加到SYSTEM变量中的PATH