是否可以防止`pipenv`将绝对解释器路径硬编码到文件中?

问题描述 投票:0回答:1

请考虑以下Pipefile

[[source]]
name = "pypi"
url = "https://pypi.org/simple"
verify_ssl = true

[dev-packages]
mysqlclient         = "==1.4.*"

[requires]
python_version      = "3.7"

我在目录/Users/hqin/tmp/PipPlay中运行以下命令。

pipenv lock
PIPENV_VENV_IN_PROJECT=true pipenv sync

然后我打开文件.venv/bin/pip,并在顶部找到以下行:

#!/Users/hqin/tmp/PipPlay/.venv/bin/python3.7

注意,当前目录的绝对路径已硬编码到文件中。

是否有一些我可以传递给pipenv的标志或可以设置的环境变量来避免这种硬编码,而是使用相对路径或不使用解释器行?

python pipenv
1个回答
0
投票

如果您确定只从根目录(在您的情况下为/Users/hqin/tmp/PipPlay/)运行脚本,则可以使用以下命令。 (我不确定这是否是最佳做法,但它对我们有用)。

#!.venv/bin/python3.7
© www.soinside.com 2019 - 2024. All rights reserved.