安装我的要求失败:
» pipenv --python 3.6.4 install
Creating a virtualenv for this project…
Using /home/myuser/.pyenv/versions/3.6.4/bin/python3.6m to create virtualenv…
⠋Running virtualenv with interpreter /home/myuser/.pyenv/versions/3.6.4/bin/python3.6m
Using base prefix '/home/myuser/.pyenv/versions/3.6.4'
New python executable in /home/myuser/.local/share/virtualenvs/svc-J_VF07t3/bin/python3.6m
Also creating executable in /home/myuser/.local/share/virtualenvs/svc-J_VF07t3/bin/python
Please make sure you remove any previous custom paths from your /home/myuser/.pydistutils.cfg file.
Installing setuptools, pip, wheel...done.
Virtualenv location: /home/myuser/.local/share/virtualenvs/svc-J_VF07t3
Pipfile.lock not found, creating…
Locking [dev-packages] dependencies…
n2.7/site-packages/pipenv/resolver.py", line 11, in <module>
import pipenv.utils
File "/home/myuser/.local/lib/python2.7/site-packages/pipenv/../pipenv/__init__.py", line 17, in <module>
from .cli import cli
File "/home/myuser/.local/lib/python2.7/site-packages/pipenv/../pipenv/cli.py", line 10, in <module>
import delegator
File "/home/myuser/.local/lib/python2.7/site-packages/pipenv/vendor/delegator.py", line 8, in <module>
from pexpect.popen_spawn import PopenSpawn
File "/home/myuser/.local/lib/python2.7/site-packages/pipenv/vendor/pexpect/popen_spawn.py", line 14, in <module>
from Queue import Queue, Empty # Python 2
ModuleNotFoundError: No module named 'Queue'
/home/myuser/.local/lib/python2.7/site-packages/pipenv/utils.py:1147: ResourceWarning: Implicitly cleaning up <TemporaryDirectory '/tmp/pipenv-cLTIqh-requirements'>
warnings.warn(warn_message, ResourceWarning)
为什么Python 2.7
?让我们检查一下virtualenv中使用的python版本:
» pipenv shell
Spawning environment shell (/bin/bash). Use 'exit' to leave.
. /home/myuser/.local/share/virtualenvs/svc-J_VF07t3/bin/activate
» . /home/myuser/.local/share/virtualenvs/svc-J_VF07t3/bin/activate
» python --version
Python 3.6.4
正确!那么pipenv
本身呢?
» which pipenv
/home/myuser/.local/bin/pipenv
所以似乎问题在于,虽然我的virtualenv
正在使用Python 3
,但pipenv
本身正在使用Python 2
(系统Python)。 pipenv
已使用系统范围的python解释器安装为recommended:
pip install --user pipenv
确实安装了,发现:
» which pipenv
/home/myuser/.local/bin/pipenv
» pipenv --version
pipenv, version 11.1.3
根据我的项目将要使用的python解释器强制重新安装pipenv
没有任何意义。
为什么pipenv
在virtualenv中安装包时使用系统python,而不是使用那个virtualenv的python?如何解耦pipenv
使用的python解释器和我的项目使用的python解释器?
答案 0 :(得分:0)
我有一个非常相似的问题。当摆弄pipenv和新的次要版本的python 3时,它开始发生。听起来似乎无济于事,解决方案是打开一个新的shell(不采购该shell),并调用pipenv shell就像我的python manage.py
命令。
以前我的错误是在整个字符串插值'%d' % foo
中抱怨python 2.7,但这在python 3中有效。