pipenv无法从pyenv(pyenv-win)获取python版本?



我尝试在python中使用pyenv(pyenv-win)和pipenv。我使用pyenv安装了一些版本的python但是,当我试图使用我通过pyenv安装的其中一个版本创建虚拟环境时。Pipenv无法从pyenv获取python版本。

pipenv --python 3.10.6
C:UsersMUZUBtest1>pipenv --python 3.10.6
Warning: Python 3.10.6 was not found on your system...
Would you like us to install CPython 3.10.6 with Pyenv? [Y/n]: n

已安装Pyenv Python版本:

C:UsersMUZUB>pyenv versions
3.10.6
3.10.7
3.11.0rc2
3.6.0
3.7.1
3.7.2
3.8.1
3.9.2
3.9.5
* 3.9.9 (set by C:UsersMUZUB.pyenvpyenv-winversion)

我默认的python版本是3.11

C:UsersMUZUBtest1>python
Python 3.11.1 (tags/v3.11.1:a7a450f, Dec  6 2022, 19:58:39) [MSC v.1934 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> exit()

当我没有指定python的特定版本时,.pipenv使用我的默认python安装来创建虚拟环境。

C:UsersMUZUBtest1>pipenv shell
Creating a virtualenv for this project...
Pipfile: C:UsersMUZUBtest1Pipfile
Using C:/Users/MUZUB/Desktop/python311/python.exe (3.11.1) to create virtualenv...
[    ] Creating virtual environment...created virtual environment CPython3.11.1.final.0-64 in 4715ms
creator Venv(dest=C:UsersMUZUB.virtualenvstest1-y9ytVeDV, clear=False, no_vcs_ignore=False, global=False, describe=CPython3Windows)
seeder FromAppData(download=False, pip=bundle, setuptools=bundle, wheel=bundle, via=copy, app_data_dir=C:UsersMUZUBAppDataLocalpypavirtualenv)
added seed packages: pip==22.3.1, setuptools==65.6.3, wheel==0.38.4
activators BashActivator,BatchActivator,FishActivator,NushellActivator,PowerShellActivator,PythonActivator
Successfully created virtual environment!
Virtualenv location: C:UsersMUZUB.virtualenvstest1-y9ytVeDV
requirements.txt found in C:UsersMUZUB instead of Pipfile! Converting...
Warning: Your Pipfile now contains pinned versions, if your requirements.txt did.
We recommend updating your Pipfile to specify the "*" version, instead.
Launching subshell in virtual environment...
Microsoft Windows [Version 10.0.22621.963]
(c) Microsoft Corporation. All rights reserved.

User环境变量:

PYENV         C:UsersMUZUB.pyenvpyenv-win
PYENV_HOME    C:UsersMUZUB.pyenvpyenv-win
PYENV_ROOT    C:UsersMUZUB.pyenvpyenv-winversions

路径:

C:UsersMUZUBDesktoppython311
C:UsersMUZUBDesktoppython311Scripts
C:UsersMUZUB.pyenvpyenv-winshims
C:UsersMUZUB.pyenvpyenv-winbin
C:UsersMUZUB.pyenvpyenv-winversions

我已经尝试改变路径的优先级。但是它不工作。

我希望在pyenv中安装的python版本可以在pipenv中使用。

编辑:

我也试过传递完整的路径。

C:UsersMUZUBDesktoppipy>pipenv --python C:UsersMUZUB.pyenvpyenv-winversions3.7.1
Usage: pipenv [OPTIONS] COMMAND [ARGS]...
Try 'pipenv -h' for help.
Error: Invalid value for '--python': Expected Python at path C:UsersMUZUB.pyenvpyenv-winversions3.7.1 does not exist
C:UsersMUZUBDesktoppipy>pipenv --python C:\Users\MUZUB\.pyenv\pyenv-win\versions\3.7.1
Usage: pipenv [OPTIONS] COMMAND [ARGS]...
Try 'pipenv -h' for help.
Error: Invalid value for '--python': Expected Python at path C:\Users\MUZUB\.pyenv\pyenv-win\versions\3.7.1 does not exist
C:UsersMUZUBDesktoppipy>pipenv --python C:/Users/MUZUB/.pyenv/pyenv-win/versions/3.7.1
Usage: pipenv [OPTIONS] COMMAND [ARGS]...
Try 'pipenv -h' for help.
Error: Invalid value for '--python': Expected Python at path C:/Users/MUZUB/.pyenv/pyenv-win/versions/3.7.1 does not exist

在我用pyenv安装的python版本中,我也看不到bin目录。

C:UsersMUZUB.pyenvpyenv-winversions3.10.6>dir
Volume in drive C is OS
Volume Serial Number is BCEC-821A
Directory of C:UsersMUZUB.pyenvpyenv-winversions3.10.6
15-12-2022  17:38    <DIR>          .
15-12-2022  17:58    <DIR>          ..
01-08-2022  22:00            19,256 api-ms-win-core-console-l1-1-0.dll
01-08-2022  22:00            18,744 api-ms-win-core-datetime-l1-1-0.dll
01-08-2022  22:00            18,744 api-ms-win-core-debug-l1-1-0.dll
01-08-2022  22:00            18,744 api-ms-win-core-errorhandling-l1-1-0.dll
01-08-2022  22:00            22,328 api-ms-win-core-file-l1-1-0.dll
01-08-2022  22:00            18,744 api-ms-win-core-file-l1-2-0.dll
01-08-2022  22:00            18,744 api-ms-win-core-file-l2-1-0.dll
01-08-2022  22:00            18,744 api-ms-win-core-handle-l1-1-0.dll
01-08-2022  22:00            19,256 api-ms-win-core-heap-l1-1-0.dll
01-08-2022  22:00            18,744 api-ms-win-core-interlocked-l1-1-0.dll
01-08-2022  22:00            19,256 api-ms-win-core-libraryloader-l1-1-0.dll
01-08-2022  22:00            21,304 api-ms-win-core-localization-l1-2-0.dll
01-08-2022  22:00            19,256 api-ms-win-core-memory-l1-1-0.dll
01-08-2022  22:00            18,744 api-ms-win-core-namedpipe-l1-1-0.dll
01-08-2022  22:00            19,768 api-ms-win-core-processenvironment-l1-1-0.dll
01-08-2022  22:00            20,792 api-ms-win-core-processthreads-l1-1-0.dll
01-08-2022  22:00            19,256 api-ms-win-core-processthreads-l1-1-1.dll
01-08-2022  22:00            18,232 api-ms-win-core-profile-l1-1-0.dll
01-08-2022  22:00            19,256 api-ms-win-core-rtlsupport-l1-1-0.dll
01-08-2022  22:00            18,744 api-ms-win-core-string-l1-1-0.dll
01-08-2022  22:00            20,792 api-ms-win-core-synch-l1-1-0.dll
01-08-2022  22:00            19,256 api-ms-win-core-synch-l1-2-0.dll
01-08-2022  22:00            19,768 api-ms-win-core-sysinfo-l1-1-0.dll
01-08-2022  22:00            18,744 api-ms-win-core-timezone-l1-1-0.dll
01-08-2022  22:00            17,856 api-ms-win-core-util-l1-1-0.dll
01-08-2022  22:00            19,768 api-ms-win-crt-conio-l1-1-0.dll
01-08-2022  22:00            22,840 api-ms-win-crt-convert-l1-1-0.dll
01-08-2022  22:00            19,256 api-ms-win-crt-environment-l1-1-0.dll
01-08-2022  22:00            20,792 api-ms-win-crt-filesystem-l1-1-0.dll
01-08-2022  22:00            19,768 api-ms-win-crt-heap-l1-1-0.dll
01-08-2022  22:00            19,256 api-ms-win-crt-locale-l1-1-0.dll
01-08-2022  22:00            27,064 api-ms-win-crt-math-l1-1-0.dll
01-08-2022  22:00            26,936 api-ms-win-crt-multibyte-l1-1-0.dll
01-08-2022  22:00            71,480 api-ms-win-crt-private-l1-1-0.dll
01-08-2022  22:00            19,768 api-ms-win-crt-process-l1-1-0.dll
01-08-2022  22:00            22,464 api-ms-win-crt-runtime-l1-1-0.dll
01-08-2022  22:00            24,888 api-ms-win-crt-stdio-l1-1-0.dll
01-08-2022  22:00            24,888 api-ms-win-crt-string-l1-1-0.dll
01-08-2022  22:00            21,304 api-ms-win-crt-time-l1-1-0.dll
01-08-2022  22:00            19,256 api-ms-win-crt-utility-l1-1-0.dll
15-12-2022  17:38    <DIR>          DLLs
15-12-2022  17:38    <DIR>          Doc
15-12-2022  17:38    <DIR>          include
15-12-2022  17:38    <DIR>          Lib
15-12-2022  17:38    <DIR>          libs
01-08-2022  22:00            32,763 LICENSE.txt
01-08-2022  22:00         1,273,168 NEWS.txt
01-08-2022  21:59           101,800 python.exe
01-08-2022  21:59           520,192 python.pdb
01-08-2022  21:59           101,800 python3.10.exe
01-08-2022  21:59            64,936 python3.dll
01-08-2022  21:59           101,800 python3.exe
01-08-2022  22:00         4,493,736 python310.dll
01-08-2022  21:59           101,800 python310.exe
01-08-2022  22:00        15,077,376 python310.pdb
01-08-2022  22:00         9,964,032 python310_d.dll
01-08-2022  22:00        11,243,520 python310_d.pdb
01-08-2022  22:00            68,608 python3_d.dll
01-08-2022  21:59           100,264 pythonw.exe
01-08-2022  22:00           536,576 pythonw.pdb
01-08-2022  21:59           100,264 pythonw3.10.exe
01-08-2022  21:59           100,264 pythonw3.exe
01-08-2022  21:59           100,264 pythonw310.exe
01-08-2022  22:00           135,168 pythonw_d.exe
01-08-2022  22:00           684,032 pythonw_d.pdb
01-08-2022  22:00           137,216 python_d.exe
01-08-2022  22:00           667,648 python_d.pdb
15-12-2022  17:38    <DIR>          Scripts
15-12-2022  17:38    <DIR>          tcl
15-12-2022  17:38    <DIR>          Tools
01-08-2022  22:00         1,001,272 ucrtbase.dll
01-08-2022  22:00            98,736 vcruntime140.dll
01-08-2022  22:00            38,304 vcruntime140_1.dll
65 File(s)     47,708,339 bytes
10 Dir(s)  481,290,395,648 bytes free

嘿,问题是你引用了pyenv下的python安装的相对路径。

你应该尝试在pyenv下安装python的绝对路径:

pipenv --python C:\Users\MUZUB\.pyenv\pyenv-win\versions\3.10.0

您可以尝试以下方法来解决此问题:

确保已将pyenv目录添加到PATH环境变量中。这将允许pipenv查找您使用pyenv安装的Python版本。

如果您正在使用pyenv-win插件,请确保您已将pyenv-win shim添加到PATH环境变量中。该shim允许您在Windows命令提示符中使用pyenv命令。

创建虚拟环境时,尝试指定Python可执行文件的完整路径。例如:pipenv --python /path/to/python.

如果您在特定项目中使用pipenv,请尝试使用——python标志来指定要用于虚拟环境的python可执行文件。例如:pipenv --python /path/to/python install.

相关内容

  • 没有找到相关文章

最新更新