如何使用pipenv为python 2.7创建虚拟环境?

Abd*_*Abd 2 python-2.7 python-3.x pipenv

C:\\Users\\Abj>python\nPython 2.7.15 (v2.7.15:ca079a3ea3, Apr 30 2018, 16:30:26) [MSC v.1500 64 \nbit (AMD64)] on win32\nType "help", "copyright", "credits" or "license" for more information.\n>>> ^Z\n\nC:\\Users\\Abj>cd Documents\\VVV\\qq\\\n\nC:\\Users\\Abj\\Documents\\VVV\\qq>pipenv install django\nCreating a virtualenv for this project\xe2\x80\xa6\nPipfile: C:\\Users\\Abj\\Documents\\VVV\\qq\\Pipfile\nUsing c:\\python\\python37-32\\python.exe (3.7.2) to create virtualenv\xe2\x80\xa6\n[    ] Creating virtual environment...Already using interpreter \nc:\\python\\python37-32\\python.exe\nUsing base prefix \'c:\\\\python\\\\python37-32\'\nNew python executable in C:\\Users\\Abj\\.virtualenvs\\qq- \nbCTw3U33\\Scripts\\python.exe\nInstalling setuptools, pip, wheel...\ndone.\n\nSuccessfully created virtual environment!\nVirtualenv location: C:\\Users\\Abj\\.virtualenvs\\qq-bCTw3U33\nCreating a Pipfile for this project\xe2\x80\xa6\nInstalling django\xe2\x80\xa6\nAdding django to Pipfile\'s [packages]\xe2\x80\xa6\nInstallation Succeeded\nPipfile.lock not found, creating\xe2\x80\xa6\nLocking [dev-packages] dependencies\xe2\x80\xa6\nLocking [packages] dependencies\xe2\x80\xa6\nSuccess!\nUpdated Pipfile.lock (4f9dd2)!\nInstalling dependencies from Pipfile.lock (4f9dd2)\xe2\x80\xa6\n================================ 2/2 - 00:00:01\nTo activate this project\'s virtualenv, run pipenv shell.\nAlternatively, run a command inside the virtualenv with pipenv run.\n\nC:\\Users\\Abj\\Documents\\VVV\\qq>pipenv run python\nPython 3.7.2 (tags/v3.7.2:9a3ffc0492, Dec 23 2018, 22:20:52) [MSC v.1916 \n32 bit (Intel)] on win32\nType "help", "copyright", "credits" or "license" for more information.\n>>> ^Z\n\nC:\\Users\\Abj\\Documents\\VVV\\qq>pipenv shell\nLaunching subshell in virtual environment\xe2\x80\xa6\nMicrosoft Windows [Version 6.1.7601]\nCopyright (c) 2009 Microsoft Corporation.  All rights reserved.\n\n(qq-bCTw3U33) C:\\Users\\Abj\\Documents\\VVV\\qq>which python\n/c/Users/Abj/.virtualenvs/qq-bCTw3U33/Scripts/python\n\n(qq-bCTw3U33) C:\\Users\\Abj\\Documents\\VVV\\qq>python -V\nPython 3.7.2\n
Run Code Online (Sandbox Code Playgroud)\n\n

我想使用 python 2.7 创建一个虚拟环境

\n\n

Python 3.7.2 是我的计算机环境中的默认版本。所以我将路径环境变量中的它更改为python 2.7.15。之后,在使用 pipelinenv 时,python 使用 python 3.7.2。

\n\n

谁能帮助我,在这种情况下我该如何使用 python 2.7.15?

\n

Abd*_*Abd 5

我从https://pypi.org/project/pipenv/得到答案,需要使用命令

pipenv --two install django
Run Code Online (Sandbox Code Playgroud)

  • 是的,您需要使用 —two 标志。 (2认同)