【问题标题】:install error thinks pythonpath is empty安装错误认为 pythonpath 为空
【发布时间】:2013-05-18 17:26:35
【问题描述】:

我正在尝试安装 scikits.nufft 包here 我下载 zip 文件,解压缩并 cd 到目录。它包含一个 setup.py 文件,所以我运行

python setup.py install

但它给了我以下与我的 PYTHONPATH 相关的错误

sudo python setup.py install
sudo: unable to resolve host Lenovo
/usr/local/lib/python2.7/dist-packages/distribute-0.6.31-py2.7.egg/setuptools/command/install_scripts.py:3: UserWarning: Module dap was already imported from None, but /usr/lib/python2.7/dist-packages is being added to sys.path
  from pkg_resources import Distribution, PathMetadata, ensure_directory
running install
Checking .pth file support in /usr/local/lib/python2.7/site-packages/
/usr/bin/python -E -c pass
TEST FAILED: /usr/local/lib/python2.7/site-packages/ does NOT support .pth files
error: bad install directory or PYTHONPATH

You are attempting to install a package to a directory that is not
on PYTHONPATH and which Python does not read ".pth" files from.  The
installation directory you specified (via --install-dir, --prefix, or
the distutils default setting) was:

    /usr/local/lib/python2.7/site-packages/

and your PYTHONPATH environment variable currently contains:

    ''

Here are some of your options for correcting the problem:

* You can choose a different installation directory, i.e., one that is
  on PYTHONPATH or supports .pth files

* You can add the installation directory to the PYTHONPATH environment
  variable.  (It must then also be on PYTHONPATH whenever you run
  Python and want to use the package(s) you are installing.)

* You can set up the installation directory to support ".pth" files by
  using one of the approaches described here:

  http://packages.python.org/distribute/easy_install.html#custom-installation-locations

Please make the appropriate changes for your system and try again.

似乎认为路径是空的,但是当我检查路径时,我得到了,

echo $PYTHONPATH
/usr/local/lib/python2.7/site-packages:/home/david/PYTHON

有谁知道为什么它会认为路径是空的?或者对这里可能出现的问题有任何其他想法。 谢谢, 戴夫

【问题讨论】:

  • 好吧,即使您的PYTHONPATH 看起来正确,在sudo 之后也不一定正确。尝试先用sudo su - 启动一个root shell,然后在从同一个shell 运行脚本之前检查PYTHONPATH 的外观。

标签: python linux path installation


【解决方案1】:

对于想要避免使用 sudo 并在本地用户下安装的人:

PYTHONPATH=~/local/lib/python2.7/site-packages/  python ./distribute_setup.py

【讨论】:

  • 谢谢,这真的很有用,但只有在我使用 bash 时才有效。也许你应该改进一下你的答案。
【解决方案2】:

在上面 Aya 的评论之后,我发现了类似的已解决问题 here 并通过添加运行它

Defaults    env_keep += "PYTHONPATH"

到 sudoers 文件。 塔, 戴夫

【讨论】:

    猜你喜欢
    • 2013-02-05
    • 2011-02-25
    • 1970-01-01
    • 2017-07-14
    • 1970-01-01
    • 1970-01-01
    • 2017-02-19
    • 1970-01-01
    • 2013-08-02
    相关资源
    最近更新 更多