pipenv如何决定我的python版本?我的默认python3版本与pipenv决定的版本不同。一个简单的例子来说明我的问题。Pipefile说的是3.8,而我的python3是3.9
pyenv_test ➤ cat requirements.txt
pexpect==4.8.0
termcolor==1.1.0
pyenv_test ➤ pipenv install
requirements.txt found, instead of Pipfile! Converting...
✔ Success!
Warning: Your Pipfile now contains pinned versions, if your requirements.txt did.
We recommend updating your Pipfile to specify the "*" version, instead.
Pipfile.lock not found, creating...
Locking [dev-packages] dependencies...
Locking [packages] dependencies...
Building requirements...
Resolving dependencies...
✔ Success!
Updated Pipfile.lock (a46966)!
Installing dependencies from Pipfile.lock (a46966)...
🐍 ▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉ 0/0 — 00:00:00
To activate this project's virtualenv, run pipenv shell.
Alternatively, run a command inside the virtualenv with pipenv run.
pyenv_test ➤ cat Pipfile
[[source]]
url = "https://pypi.org/simple"
verify_ssl = true
name = "pypi"
[packages]
pexpect = "==4.8.0"
termcolor = "==1.1.0"
[dev-packages]
[requires]
python_version = "3.8"
pyenv_test ➤ which python3
/Library/Frameworks/Python.framework/Versions/3.9/bin/python3
我发现的另一个问题是它生成的requirement.text与最初创建的Pipefile不同
pyenv_test ➤ pipenv lock -r
#
# These requirements were autogenerated by pipenv
# To regenerate from the project's Pipfile, run:
#
# pipenv lock --requirements
#
-i https://pypi.org/simple
pexpect==4.8.0
ptyprocess==0.6.0
termcolor==1.1.0
与最初生成管道文件的my requirements.txt相比,它添加了ptyprocess。正如评论所指出的,pexpect使用ptyprocess。但为什么Pipefile会将其作为另一项要求添加
查看specifying a python version上的
pipenv
文档,它指出:我猜您在升级到python 3.9之前初始化了
pipenv
项目如果要更新
Pipfile
以指定特定的python版本,只需执行以下操作:当然,您也可以手动更新
python_version
中的Pipfile
我对pipenvhttps://github.com/pypa/pipenv/issues/4546提出了一个问题,在与一名维护人员讨论之后,我现在明白了问题发生的原因
对于我的第一个问题,当run
pipenv install
pipenv重用现有的python3.8时,即不会重新创建venv。我觉得这看起来像个问题,为什么要在新项目上重用venv对于我的第二个问题,它确实帮助我理解“生成确定性构建”的含义。pexpect使用ptyprocess。我检查pexpect的setup.pyhttps://github.com/pexpect/pexpect/blob/master/setup.py
因此,通过在requirement.txt中指定
ptyprocess==0.6.0 & pexpect==4.8.0
,确实可以生成确定性构建相关问题 更多 >
编程相关推荐