2015-07-29 27 views
9

Tôi đang gặp sự cố khi cố gắng tạo thư mục virtualenv của mình vì thiết bị đầu cuối của tôi cho biết rằng virtualenv có vẻ không được cài đặt.Virtualenv: Lệnh không được tìm thấy

Tôi đã làm gì:

sudo pip install virtualenv 

với phản ứng này:

The directory '/Users/ricardogonzales/Library/Caches/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag. 
The directory '/Users/ricardogonzales/Library/Caches/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag. 
Collecting virtualenv 
/Library/Python/2.7/site-packages/pip/_vendor/requests/packages/urllib3/util/ssl_.py:90: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. For more information, see https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning. 
    InsecurePlatformWarning 
    Downloading virtualenv-13.1.0-py2.py3-none-any.whl (1.7MB) 
    100% |████████████████████████████████| 1.7MB 59kB/s 
Installing collected packages: virtualenv 
Successfully installed virtualenv-13.1.0 

Sau đó tôi đã chạy virtualenv venv và tôi nhận được câu trả lời này: command not found

Tôi đã thực hiện lệnh này (brew info python) giống như những người khác ở đây với cùng một vấn đề nhưng phản ứng của họ từ thiết bị đầu cuối không giống như của tôi.

brew đáp ứng thông tin:

python: stable 2.7.10 (bottled), HEAD 
Interpreted, interactive, object-oriented programming language 
https://www.python.org 
Not installed 
From: https://github.com/Homebrew/homebrew/blob/master/Library/Formula/python.rb 
==> Dependencies 
Build: pkg-config ✘ 
Required: openssl ✘ 
Recommended: readline ✘, sqlite ✘, gdbm ✘ 
Optional: homebrew/dupes/tcl-tk ✘, berkeley-db4 ✘ 
==> Options 
--universal 
    Build a universal binary 
--with-berkeley-db4 
    Build with berkeley-db4 support 
--with-poll 
    Enable select.poll, which is not fully implemented on OS X (https://bugs.python.org/issue5154) 
--with-quicktest 
    Run `make quicktest` after the build (for devs; may fail) 
--with-tcl-tk 
    Use Homebrew's Tk instead of OS X Tk (has optional Cocoa and threads support) 
--without-gdbm 
    Build without gdbm support 
--without-readline 
    Build without readline support 
--without-sqlite 
    Build without sqlite support 
--HEAD 
    Install HEAD version 
==> Caveats 
Pip and setuptools have been installed. To update them 
    pip install --upgrade pip setuptools 

You can install Python packages with 
    pip install <package> 

They will install into the site-package directory 
    /usr/local/lib/python2.7/site-packages 

See: https://github.com/Homebrew/homebrew/blob/master/share/doc/homebrew/Homebrew-and-Python.md 

Tôi không biết làm thế nào nó nói "Không được cài đặt" nhưng khi tôi chạy python --version Tôi nhận được Python 2.7.6 nhưng nếu tôi đi đến usr/local/bin Tôi không thể xem bất kỳ python 2,7 hoặc cái gì tôi thấy là rất nhiều python3.

Bất kỳ trợ giúp nào? hoặc gợi ý để cố gắng giải quyết vấn đề này sẽ rất được giải thích.

ĐÁP:

Tôi đã giải quyết vấn đề này gỡ bỏ cài đặt virtualenv và cài đặt lại mà không cần bất kỳ cấu hình thêm hoặc một cái gì đó.

sudo pip uninstall virtualenv 
sudo pip install virtualenv 
+2

'sudo apt-get cài đặt virtualenv' – IanAuld

+0

@IanAuld Tôi quên nói rằng tôi đang sử dụng Mac OS X – RicardoGonzales

+0

Bạn có thể cần phải đăng xuất/đăng nhập để nó hoạt động và sử dụng' mkvirtualenv' chứ không phải 'virtualenv '. – bufh

Trả lời

3

Bạn đã cài đặt Python 2.7.10 theo brew info. python --version trả về 2.7.6, vì vậy bạn có thể đang sử dụng Python đi kèm với OS X. Để khắc phục điều đó, hãy chạy: brew link python, xác nhận rằng nó được liên kết chính xác bằng cách chạy which python. Nó sẽ trả lại /usr/local/bin/python (trừ khi bạn đã cài đặt Homebrew trong một thư mục khác hơn /usr/local).

Sau đó, bạn có thể cần cài đặt lại virtualenv bằng lệnh bạn đã sử dụng trước đó, vì brew link python cũng sẽ cập nhật đường dẫn đến pip (phiên bản pip được liên kết với cài đặt Python của bạn trong /usr/local).

+0

Đã đến đây vì giờ tôi không thể nhận được 'autopep8' hoạt động bình thường sau khi cài đặt qua 'pip' (tôi phải nghiêm túc vặn vẹo điều gì đó trong 24 giờ qua trong khi cố gắng thiết lập mọi thứ cho bộ công cụ dòng lệnh AWS EC2). Tôi tiếp tục nhận lệnh '-bash: không tìm thấy' lỗi khi cố chạy autopep8 trên một tệp. Dù sao, mọi thứ đang chạy hoàn hảo ngay bây giờ, cảm ơn! – AdjunctProfessorFalcon

Các vấn đề liên quan