7

rootアクセス権のないLinuxマシンにsettuptoolsをインストールしようとしています。私はすでに仮想Pythonを作成しています。

dgomez:~/download> which python
/home/dgomez/bin/python

次の手順を実行すると、エラーが発生します。

/home/dgomez/bin/python ez_setup.py 

Downloading http://pypi.python.org/packages/2.7/s/setuptools/setuptools-0.6c11-py2.7.egg
error: can't create or remove files in install directory

The following error occurred while trying to add or remove files in the
installation directory:

[Errno 2] No such file or directory: '/usr/local/lib/python2.7/site-packages/test-easy-install-8816.pth'

The installation directory you specified (via --install-dir, --prefix, or
the distutils default setting) was:

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

This directory does not currently exist.  Please create it and try again, or
choose a different installation directory (using the -d or --install-dir

オプション)。

これを修正する方法を知りたいのですが。他のフォーラムで、ユーザーがディレクトリを作成して修正したところを確認しましたが、私の場合、ディレクトリを作成できないため、rootアクセス権がありません。ありがとう

アップデート

Pythonを実行しました

ez_setup.py --install-dir=/home/dgomez/lib/python2.7/site-packages/

Buはまだエラーを受け取ります:

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:

/home/dgomez/lib/python2.7/site-packages/

and your PYTHONPATH environment variable currently contains:

''
4

2 に答える 2

5

The error message tells you exactly what to do, use the --install-dir or --prefix option so the package installs to your virtual Python installation instead of the default location.

This might look something like this:

/home/dgomez/bin/python ez_setup.py --prefix=/home/dgomez

Or with --install-dir:

/home/dgomez/bin/python ez_setup.py --install-dir=/home/dgomez/lib/python2.7/site-packages

Note that you may need to modify the directories used in the options above depending on the actual location of the site-packages directory of your Python installation.

edit: To fix the new error you are seeing, you need to add that directory to the PYTHONPATH environment variable, you can do that with the following command:

export PYTHONPATH=$PYTHONPATH:/home/dgomez/lib/python2.7/site-packages/

If you are using bash on a Mac or GNU/Linux distro, you can add that line to your ~/.bashrc file so that you won't need to run it manually.

于 2013-02-19T20:52:05.900 に答える
1

私は同じ問題に遭遇しました。どういうわけかこのディレクトリは削除されていたので、pipとsetuptoolsはありませんでした。私が解決した方法は、pipのWebサイトから直接pipをダウンロードすることです。get-pip.pyからpipファイルをダウンロードして解決しました。ダウンロード後、このファイルをPythonの方向に実行するだけで、このsetuptoolsを再度使用できます。

于 2016-08-19T19:06:54.140 に答える