Pipenv shell not recognized after installing python and pipenv

7.2k views Asked by At

Problem Introduction Language version: Python 3.8 Operating system: Windows 10 Any other relevant software: Jupyter Notebook and html-requests

Context:

I am trying to install pipenv and follow along with this tutorial on using pipenv. I was only able to successfully able to install requests after adding a "-m" (as seen in the second chunk of code below). I don't even know what "-m" even means nor how I knew to do that. My goal and expected outcome is to open a pipenv shell.

Actual outcome:

after that I received this error when I tried to open a 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

Things I have tried: The code I inserted before the error:

PS C:\Users\Cullen Harris\desktop\cfeproj> pipenv install requests
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 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.
3

There are 3 answers

2
CullerWhale On BEST ANSWER

I could not figure out why I had this problem. However, one solution was to use pycharm instead of the terminal. I am not sure why it worked, but it did!

2
Mohammad Abbasi On

In the terminal go to the project directory (cd project_directory) and type this command to specify virtual environment location:
pipenv --venv
In windows the output of the command is something like this:

C:\Users\man.virtualenvs\BlogProject-K0fflSCh

Copy that and now write this command to activate the virtual environment: In windows:
C:\Users\man.virtualenvs\BlogProject-K0fflSCh\Scripts\activate

In Linux use bin instead of Scripts.

0
Shovely Joe On

I'm having the same issue, and have spent the better part of the day trying to figure it out. And I was determined to solve it without PyCharm(through VS Code), so here it is if anyone needs it:

First of all, make sure the pip is in the right place. Look at the place the interpreter is pulling the file from, and then make sure the files exist. (I know this sounds stupid, but I have Python38 and Python39 folders, and they installed in one and pulled from the other. The Scripts folder should contain the following pips

Open up the Command Prompt, navigate to the folder and run python -m venv env. Then, select the interpreter -- it should contain env. Finally, run pipenv shell in the terminal.

If you're having any issues, try reloading the window. You should be able to use pipenv to install any external library now.

Additional resources from Visual Studio Code.

Edit: Make sure you're using the Power Shell and/or Bash, may not work on the Command Prompt.