簡體   English   中英

安裝python settuptools時發生錯誤-沒有這樣的文件或目錄:'/usr/local/lib/python2.7/site-packages/test-easy-install-8811.pth'

[英]Error when installing python settuptools - No such file or directory: '/usr/local/lib/python2.7/site-packages/test-easy-install-8811.pth'

我正在嘗試在沒有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

選項)。

我想知道如何解決這個問題。 我在其他論壇上看到用戶通過創建目錄來修復該目錄,但是在我的情況下,我沒有超級用戶訪問權限,因為我無法創建目錄。 謝謝

更新

我跑了蟒蛇

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:

''

錯誤消息會告訴您確切的操作,請使用--install-dir--prefix選項,以便將程序包安裝到虛擬Python安裝而不是默認位置。

這可能看起來像這樣:

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

--install-dir

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

請注意,您可能需要修改以上選項中使用的目錄,具體取決於Python安裝的site-packages目錄的實際位置。

編輯:要解決新錯誤,您需要將該目錄添加到PYTHONPATH環境變量中,可以使用以下命令進行操作:

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

如果在Mac或GNU / Linux發行版上使用bash,則可以將該行添加到~/.bashrc文件中,這樣就無需手動運行它。

我遇到了同樣的問題。 不知何故,此目錄已被刪除,因此我沒有pip和setuptools。 我解決的方法是直接從pip網站下載pip。 我通過從get-pip.py下載pip文件解決了該問題。 下載后,只需按python方向運行此文件,即可再次使用此setuptools。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM