问题描述
试图让我的Ubuntu电脑上的pip工作。 pip似乎适用于python2.7,但不适用于其他人。
这是问题所在:
$ pip
Traceback (most recent call last):
File "/usr/local/bin/pip", line 9, in <module>
load_entry_point('pip==1.4.1', 'console_scripts', 'pip')()
File "/usr/local/lib/python3.4/dist-packages/setuptools-1.1.5-py3.4.egg /pkg_resources.py", line 357, in load_entry_point
def get_entry_info(dist, group, name):
File "/usr/local/lib/python3.4/dist-packages/setuptools-1.1.5-py3.4.egg/pkg_resources.py", line 2394, in load_entry_point
break
File "/usr/local/lib/python3.4/dist-packages/setuptools-1.1.5-py3.4.egg/pkg_resources.py", line 2108, in load
name = some.module:some.attr [extra1,extra2]
ImportError: No module named 'pip'
$ which pip
/usr/local/bin/pip
$ python2.7 -m pip //here can be just python, btw
Usage:
/usr/bin/python2.7 -m pip <command> [options]
//and so on...
$ python3.4 -m pip
/usr/bin/python3.4: No module named pip
从home /user /.pip /pip.log:
Exception:
Traceback (most recent call last):
File "/usr/lib/python2.7/dist-packages/pip/basecommand.py", line 122, in main
status = self.run(options, args)
File "/usr/lib/python2.7/dist-packages/pip/commands/install.py", line 283, in run
requirement_set.install(install_options, global_options, root=options.root_path)
File "/usr/lib/python2.7/dist-packages/pip/req.py", line 1431, in install
requirement.uninstall(auto_confirm=True)
File "/usr/lib/python2.7/dist-packages/pip/req.py", line 598, in uninstall
paths_to_remove.remove(auto_confirm)
File "/usr/lib/python2.7/dist-packages/pip/req.py", line 1836, in remove
renames(path, new_path)
File "/usr/lib/python2.7/dist-packages/pip/util.py", line 295, in renames
shutil.move(old, new)
File "/usr/lib/python2.7/shutil.py", line 303, in move
os.unlink(src)
OSError: [Errno 13] Permission denied: '/usr/bin/pip'
没有/usr /bin /pip btw。
我怎么能解决这个问题才能正常使用pip和python 3.4?我正在尝试使用pycharm,但它的包管理器也陷入了这个问题。
谢谢你的关注!
最佳解决方案
你已经为python 2安装了pip,但没有安装python 3。
Ubuntu分发python-pip
,python3-pip
,python-setuptools
和python3-setuptools
软件包,您可以根据需要安装(apt-get install
等)。此后,请注意pip
安装用于python 2,pip3
安装用于python 3(类似于python
和python3
)。
Setuptools可以说是为包提供了python的”build”进程,而Pip提供了它的”install”进程。通常你想要两个在场。
如果你想要最新的pip /setuptools,你总是可以从PyPA的bootstrap网站获得它:
$ curl https://bootstrap.pypa.io/get-pip.py | python3.4
之后,您可以为适当的python安装最新的setuptools,例如
$ python{2.7,3.4} -m pip install -U setuptools
如果您尝试为系统python安装这些,则可能需要root /sudo
。
次佳解决方案
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
sudo python3 get-pip.py
确认其安装:
pip3 --version
要么
python3 -m pip --version
现在继续使用以下方法安装所需的软件包(例如numpy
):
pip3 install numpy
要么
python3 -m pip install numpy
以下是参考:https://pip.pypa.io/en/stable/installing/