2011-10-01 18 views
13

Tôi cố gắng để sử dụng easy_install để cài đặt một module gọi là yêu cầu bằng cách làmKhông thể sử dụng easy_install để cài đặt module Python

easy_install requests 

này làm việc tốt một tuần trước đây khi tôi còn sử dụng Python 2.6.5 nhưng ngày nay Tôi đã cài đặt Python 2.7.2 và sau đó cố gắng để import requests trong một trong các tập lệnh của tôi nhưng nó không thành công. sau đó tôi đã cố gắng cài đặt lại các yêu cầu với easy_install requests nhưng đã nhận lỗi này

install_dir /usr/local/lib/python2.6/dist-packages/ 
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 13] Permission denied: '/usr/local/lib/python2.6/dist-packages/test-easy-install-15207.pth' 

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

    /usr/local/lib/python2.6/dist-packages/ 

Perhaps your account does not have write access to this directory? If the 
installation directory is a system-owned directory, you may need to sign in 
as the administrator or "root" account. If you do not have administrative 
access to this machine, you may wish to choose a different installation 
directory, preferably one that is listed in your PYTHONPATH environment 
variable. 

For information on other options, you may wish to consult the 
documentation at: 

    http://packages.python.org/distribute/easy_install.html 

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

Vì vậy, tôi đã nói đi cài đặt lại easy_install và tôi đã đi đến http://pypi.python.org/pypi/setuptools và học tôi phải

xóa tất cả setuptools * .egg và setuptools Tệp .pth từ thư mục gói trang web của hệ thống (và bất kỳ thư mục sys.path nào khác) FIRST.

Vì vậy, tôi đã làm điều này. Sau đó tôi đã cài đặt lại các công cụ thiết lập từ setuptools-0.6c11-py2.7.egg. Dường như thành công nhưng khi tôi chạy easy_install requests tôi về cơ bản là lỗi tương tự, ngoại trừ thư mục python2.6/dist-gói bây giờ python2.7/site-packages

[email protected]:~$ easy_install requests 
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 13] Permission denied: '/usr/local/lib/python2.7/site-packages/test-easy-install-16253.write-test' 

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

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

Perhaps your account does not have write access to this directory? If the 
installation directory is a system-owned directory, you may need to sign in 
as the administrator or "root" account. If you do not have administrative 
access to this machine, you may wish to choose a different installation 
directory, preferably one that is listed in your PYTHONPATH environment 
variable. 

For information on other options, you may wish to consult the 
documentation at: 

    http://peak.telecommunity.com/EasyInstall.html 

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

Ngoài ra, khi tôi làm tab easy_install và nhấn I nhận các tùy chọn này

easy_install  easy_install-2.6 easy_install-2.7 

Làm thế nào để easy_install-2.6 có ở đó?

Làm cách nào để cài đặt lại dễ dàng?

Trả lời

16

Bạn đã thử sử dụng sudo như thế này?

sudo easy_install requests 

Hoặc chỉ định thư mục cài đặt vào thư mục mà bạn có quyền ghi.

easy_install --install-dir=/home/foo/bar 

Nhưng bạn thực sự nên sử dụng PIP thay vì easy_install. Nó tốt hơn nhiều và có nhiều tính năng hơn.

+2

vâng tôi đã sudo easy_install requests' nhưng điều đó không làm việc, hoặc. Vấn đề là cái gì đó bị hỏng với đường dẫn Python của tôi có vẻ như vậy. easy_install hoặc Python 2.7.2 đang tìm kiếm trên các đường dẫn sai mà tôi nghĩ. Giống như Python 2.7.2 đang tìm trong thư mục python2.6/dist-packages. Không chắc. – Classer

+0

Tôi cũng đang điều hướng điều này và không có 'sudo' hoặc tôi chỉ sử dụng nó. – Amanda

4

Bạn nên sử dụng virtualenv trên các bản phân phối Linux dựa trên gói để các tập lệnh Python không can thiệp vào các gói khác hoặc xung đột với trình quản lý gói của hệ điều hành.

http://workaround.org/easy-install-debian

4

Sau đây làm việc cho tôi với Ubuntu 12.10 cài đặt easy_install sau đó pip:

sudo apt-get install python-virtualenv 
curl -O https://raw.github.com/pypa/pip/master/contrib/get-pip.py 
sudo python get-pip.py 
2

Bạn đã thử thêm python.framework mới của bạn để đường dẫn? Trên sư tử núi tôi đã thêm /Library/Frameworks/Python.framework/Versions/3.3/bin/ đến /etc/paths và sau đó tôi có thể sử dụng easy_install-3.3 và pip-3.3

1

Nó có thể là một trường hợp đơn giản của bạn bị thiếu "sudo" ở phía trước. Bạn có thể thử với yêu cầu cài đặt sudo dễ dàng không

đặt "sudo" sẽ thêm quyền cần thiết.

1

Sử dụng Sudo trước easy_install có thể giải quyết vấn đề của bạn

Sudo easy_install requests 

nhờ