我在Ubuntu 12.04中同时安装了python2.7和python3.2。 符号链接python链接到python2.7。

当我输入:

sudo pip install package-name

它将默认安装python2版本的package-name。

有些包同时支持python2和python3。 如何通过pip安装python3版本的package-name ?


当前回答

你应该安装所有依赖项: Sudo apt-get install build-essential python3-dev python3-setuptools python3-numpy python3-scipy libatlas-dev libatlas3gf-base 安装pip3(如果您已经安装,请参阅步骤3): Sudo apt-get install python3-pip 我通过pip3安装scikit-learn pip3 install -U scikit-learn 打开终端并输入python3环境,输入import sklearn来检查它。

其他回答

很容易:

sudo aptitude install python3-pip
pip-3.2 install --user pkg

如果你想要Python 3.3,这不是Ubuntu 12.10的默认设置:

sudo aptitude install python3-pip python3.3
python3.3 -m pip.runner install --user pkg

如果你在两个python中都安装了pip,并且都在你的路径中,只需使用:

$ pip-2.7 install PACKAGENAME
$ pip-3.2 install PACKAGENAME

引用:

http://www.pip-installer.org/docs/pip/en/0.8.3/news.html#id4 https://github.com/pypa/pip/issues/200

这是问题2812520的副本

老问题了,但没有一个答案能让我满意。我的一个系统运行的是Ubuntu 12.04 LTS,由于某种原因,Python 3没有python3-pip或Python -pip包。下面是我所做的(所有命令都以root身份执行):

Install setuptools for Python3 in case you haven't. apt-get install python3-setuptools or aptitude install python3-setuptools With Python 2.4+ you can invoke easy_install with specific Python version by using python -m easy_install. So pip for Python 3 could be installed by: python3 -m easy_install pip That's it, you got pip for Python 3. Now just invoke pip with the specific version of Python to install package for Python 3. For example, with Python 3.2 installed on my system, I used: pip-3.2 install [package]

直接执行pip二进制文件。

首先找到您想要的PIP版本。

jon-mint python3.3 # whereis ip
ip: /bin/ip /sbin/ip /usr/share/man/man8/ip.8.gz /usr/share/man/man7/ip.7.gz

然后执行。

jon-mint python3.3 # pip3.3 install pexpect
Downloading/unpacking pexpect
  Downloading pexpect-3.2.tar.gz (131kB): 131kB downloaded
  Running setup.py (path:/tmp/pip_build_root/pexpect/setup.py) egg_info for package pexpect

Installing collected packages: pexpect
  Running setup.py install for pexpect

Successfully installed pexpect
Cleaning up...

你也可以运行pip3 install packagename而不是pip,