简体   繁体   English

如何确保pip将软件包安装到python 3?

[英]How to make sure pip installs packages to python 3?

I am seeing some weird stuff on my system: 我在系统上看到一些奇怪的东西:

$ pip install python-binance-api
...Library/Python/2.7/lib/python/site-packages (from python-binance-api) (3.13.2)
...

python versions: python版本:

$ python --version
Python 2.7.14
 10:05 PM   ~/kittycapital   add_more_curr
$ python3 --version
Python 3.6.4

My pip is still installing to python 2.7 when I want it to install on python3. 当我希望将其安装在python3上时,我的pip仍在安装至python 2.7。 How do I get it to do this? 我该怎么做呢?

If I want the commands pip and python to point to python 3.7, what can I do? 如果我希望命令pippython指向python 3.7,该怎么办?

Solution 1 解决方案1

python3 -m pip install xxx
# for example: python3.7 -m pip install requests

Solution 2 解决方案2

virtualenv --python=python3.7 venv
source venv/bin/activate
pip install requests

Solution 3 解决方案3

pipenv --python 3.7   # python3 -m pip install pipenv --user
pipenv shell
pipenv install requests

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM