问题描述
问题简介 语言版本:Python 3.8 作业系统:Windows 10 其他任何相关软件:Jupyter Notebook和html-requests
上下文:
我正在尝试安装pipenv并跟随this tutorial on using pipenv。添加“ -m”后,我才能够成功安装请求(如下面的第二段代码所示)。我什至不知道“ -m”的含义,也不知道我怎么做。我的目标和预期结果是打开pipenv Shell。
实际结果:
PS C:\Users\Cullen Harris\desktop\cfeproj> pipenv shell
pipenv : The term 'pipenv' is not recognized as the name of a cmdlet,function,script file,or operable program.
Check the spelling of the name,or if a path was included,verify that the path is correct and try again.
At line:1 char:1
+ pipenv shell
+ ~~~~~~
+ CategoryInfo : ObjectNotFound: (pipenv:String) [],CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
PS C:\Users\Cullen Harris\desktop\cfeproj> pipenv install requests
pipenv : The term 'pipenv' is not recognized as the name of a cmdlet,verify that the path is correct and try again.
At line:1 char:1
+ pipenv install requests
+ ~~~~~~
+ CategoryInfo : ObjectNotFound: (pipenv:String) [],CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
PS C:\Users\Cullen Harris\desktop\cfeproj> python -m pipenv install requests
Creating a virtualenv for this project…
Pipfile: C:\Users\Cullen Harris\desktop\cfeproj\Pipfile
Using C:/Users/Cullen Harris/AppData/Local/Programs/Python/python38-32/python.exe (3.8.6) to create virtualenv…
[= ] Creating virtual environment...created virtual environment Cpython3.8.6.final.0-32 in 2512ms
creator Cpython3Windows(dest=C:\Users\Cullen Harris\.virtualenvs\cfeproj-xPOGFEhb,clear=False,global=False)
seeder FromAppData(download=False,pip=bundle,setuptools=bundle,wheel=bundle,via=copy,app_data_dir=C:\Users\Cullen Harris\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\Local\pypa\virtualenv)
added seed packages: pip==20.2.3,setuptools==50.3.0,wheel==0.35.1
activators BashActivator,BatchActivator,FishActivator,PowerShellActivator,PythonActivator,XonshActivator
Successfully created virtual environment!
Virtualenv location: C:\Users\Cullen Harris\.virtualenvs\cfeproj-xPOGFEhb
Creating a Pipfile for this project…
Installing requests…
Adding requests to Pipfile's [packages]…
Installation Succeeded
Pipfile.lock not found,creating…
Locking [dev-packages] dependencies…
Locking [packages] dependencies…
Building requirements...
Resolving dependencies...
Success!
Updated Pipfile.lock (fbd99e)!
Installing dependencies from Pipfile.lock (fbd99e)…
================================ 0/0 - 00:00:00
To activate this project's virtualenv,run pipenv shell.
Alternatively,run a command inside the virtualenv with pipenv run.
解决方法
我不知道为什么会有这个问题。但是,一种解决方案是使用pycharm代替终端。我不知道为什么它起作用,但是它起作用了!
,我遇到了同样的问题,我花了一天中的大部分时间试图解决这个问题。我决心在没有 PyCharm 的情况下解决它(通过 VS Code),所以如果有人需要它,这里是:
首先,确保 pip 在正确的位置。查看解释器从中提取文件的位置,然后确保文件存在。 (我知道这听起来很愚蠢,但我有 Python38 和 Python39 文件夹,它们安装在一个文件夹中并从另一个文件夹中拉出。Scripts folder
应包含以下内容
pips
打开命令提示符,导航到文件夹并运行 python -m venv env
。
然后,选择解释器——它 should contain env。
最后,在终端中运行 pipenv shell
。
如果您遇到任何问题,请尝试重新加载窗口。您现在应该可以使用 pipenv
安装任何外部库。
Additional resources from Visual Studio Code.
编辑:确保您使用的是 Power Shell 和/或 Bash,可能无法在命令提示符下运行。