How to use pip with python3.5 after upgrade from 3

2019-06-15 13:05发布

I'm on Ubuntu and I have python2.7, (it came pre-installed) python3.4, (used before today) and python3.5, which I upgraded to today, installed in parallel. They all work fine on their own.

However, I want to use pip to install some packages, and I can't figure out how to do this for my 3.5 installation because pip installs for 2.7 and pip3 installs python 3.4 packages.

For instance, I have asyncio installed on 3.4, but I can't import it from 3.5. When I do pip3 install aysncio, it tells me the requirement is already satisfied.

I'm a bit of a newbie, but I did some snooping around install directories and couldn't find anything and I've googled to no avail.

2条回答
对你真心纯属浪费
2楼-- · 2019-06-15 13:48

Another way would be to setup a virtual environment:

$ python3.4 -m venv envdir
$ source envdir/bin/activate
$ pip --version

Obviously, this won't install the packages globally and you'll have to source venv/bin/activate every time you wan to make use of it.

查看更多
Luminary・发光体
3楼-- · 2019-06-15 13:50

I suppose you can run pip through Python until this is sorted out. (https://docs.python.org/dev/installing/)

A quick googling seems to indicate that this is indeed a bug. Try this and report back:

python3.4 -m pip --version
python3.5 -m pip --version

If they report different versions then I guess you're good to go. Just run python3.5 -m pip install package instead of pip3 install package to install 3.5 packages.

查看更多
登录 后发表回答