安装错误认为pythonpath为空

2024-06-11 06:07:26 发布

您现在位置:Python中文网/ 问答频道 /正文

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

python setup.py install

但它给了我以下与我的Python有关的错误

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

有人知道它为什么会认为这条路是空的吗??或者对这里的问题有其他的想法。 谢谢, 戴夫


Tags: installthetopyyoulibpackagesusr
2条回答

在上面的Aya注释之后,我发现了类似的已解决问题here,并通过添加

Defaults    env_keep += "PYTHONPATH"

到sudoers文件。 助教, 戴夫

对于那些希望避免sudo并在本地用户下安装的用户:

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

相关问题 更多 >