在Linux中,如果我输入
which python2.7
我得到/usr/bin/python2.7
。如果我输入/usr/bin/python2.7
以启动Python2.7环境,而我输入import pandas as pd
则可以正常工作。
现在,我正在与shebang #!/usr/bin/python2.7
在同一服务器上的apache2上运行python文件
下一行我放了import pandas as pd
,错误日志显示了No module named pandas
。我不明白为什么如果使用相同的Python也不起作用?
这也是我是否python2.7 -m site
sys.path = [
'/home/archie',
'/usr/lib/python2.7',
'/usr/lib/python2.7/plat-x86_64-linux-gnu',
'/usr/lib/python2.7/lib-tk',
'/usr/lib/python2.7/lib-old',
'/usr/lib/python2.7/lib-dynload',
'/home/archie/.local/lib/python2.7/site-packages',
'/usr/local/lib/python2.7/dist-packages',
'/usr/local/lib/python2.7/dist-packages/requests-2.21.0-py2.7.egg',
'/usr/local/lib/python2.7/dist-packages/urllib3-1.24.1-py2.7.egg',
'/usr/local/lib/python2.7/dist-packages/chardet-3.0.4-py2.7.egg',
'/usr/local/lib/python2.7/dist-packages/certifi-2018.11.29-py2.7.egg',
'/usr/local/lib/python2.7/dist-packages/simple_salesforce-0.74.2-py2.7.egg',
'/usr/lib/python2.7/dist-packages',
]
如果我这样做pip2.7 uninstall pandas
我得到
Uninstalling pandas-0.23.4:
Would remove:
/home/archie/.local/lib/python2.7/site-packages/pandas-0.23.4.dist-info/*
/home/archie/.local/lib/python2.7/site-packages/pandas/*
答案 0 :(得分:0)
如果您使用的是类似bash的外壳,则可能还需要尝试键入type python2.7
。完全有可能是别名,which
完全没有意识到。