2017-07-04 145 views
1

有沒有人處於相同的情況?安裝pip後沒有名爲'pip'的模塊

$ which pip 
    /usr/local/bin/pip 
    $pip 
    Traceback (most recent call last): 
     File "/usr/local/bin/pip", line 7, in <module> 
     from pip import main 
    ModuleNotFoundError: No module named 'pip' 
    $ python 
    Python 2.7.6 (default, Oct 26 2016, 20:30:19) 
    [GCC 4.8.4] on linux2 
    Type "help", "copyright", "credits" or "license" for more information. 
    >>> import pip 
    >>> pip.__version__ 
    '9.0.1' 

同樣的情況發生在其他包

$ easy_install 
    Traceback (most recent call last): 
     File "/usr/local/bin/easy_install", line 7, in <module> 
     from setuptools.command.easy_install import main 
    ModuleNotFoundError: No module named 'setuptools' 
    $ virtualenv 
    Traceback (most recent call last): 
     File "/usr/local/bin/virtualenv", line 7, in <module> 
     from virtualenv import main 
    ModuleNotFoundError: No module named 'virtualenv' 

它們都安裝。

的Ubuntu 16.04的Python 2

+0

請嘗試'python -m pip install PACKAGENAME'並告訴我們,如果它工作 – Michal

+0

它的工作原理,你能告訴我爲什麼嗎? – ycd

+0

它接縫是路徑問題。我現在不是在用我的Linux電腦,但在晚上我會嘗試一些並回答,如果沒有其他人會這樣做的話 – Michal

回答

3

安裝的Ubuntu 10.10小牛PIP和的virtualenv和新

$ sudo apt-get install python-pip python-dev build-essential 
$ sudo pip install --upgrade pip 
$ sudo pip install --upgrade virtualenv 

對於舊版本的Ubuntu

sudo apt-get install python-setuptools python-dev build-essential 
sudo easy_install pip 
$ sudo pip install --upgrade virtualenv 

希望這有助於..!

+0

它也適用於Ubuntu Xenial(Windows 10) –