Shebang没有相同的进口商品?

时间:2019-01-30 21:33:28

标签: python pandas

在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/*

1 个答案:

答案 0 :(得分:0)

如果您使用的是类似bash的外壳,则可能还需要尝试键入type python2.7。完全有可能是别名,which完全没有意识到。