python pip install没有在正确的python版本下安装

2021-04-11 15:17:15 发布

您现在位置:Python中文网/ 问答频道 /正文

workon dal                                                               ✭ ✱
(dal)➜  Server (master)

检查python版本是否正确

^{pr2}$

但安装时,应按2.7而不是3.4.2安装

(dal)➜  Server (master) pip install -r requirements.txt                                          ✭ ✱
Requirement already satisfied (use --upgrade to upgrade): Flask==0.10.1 in /Users/partuck/.virtualenvs/dal/lib/python2.7/site-packages (from -r requirements.txt (line 1))
...
Requirement already satisfied (use --upgrade to upgrade): argparse in /Users/partuck/.virtualenvs/dal/lib/python2.7/site-packages (from stevedore==1.2.0->-r requirements.txt (line 13))

注意路径中的python2.7。在

如何告诉pip在3.4.2下安装它?在

编辑: 例如,试过了

(dal)➜  Server (master) pip3 install itsdangerous

它将其安装在主python环境下,而不是专门安装在dalvirtualenv中。 证明: (dal)➜服务器(主)pip3安装其危险

Requirement already satisfied (use --upgrade to upgrade): itsdangerous in /usr/local/lib/python3.4/site-packages
Cleaning up...

编辑2:

打字时 eval "$(pyenv init -)" 根据pyenv指南中的建议,我看到
python—版本 Python 3.4.2 但是,当进入Pyton控制台时

 python                                                                ✭ ✱
Python 2.7.9 (default, Dec 19 2014, 06:00:59)
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.56)] on darwin
Type "help", "copyright", "credits" or "license" for more information.