Windows reports error when trying to install package using pipenv

78k views Asked by At

I installed pipenv by following the instructions here. From the Windows command prompt I ran

pip install --user pipenv

which returned the message

Successfully installed pipenv-5.3.3

Now I want to install the requests package using pipenv, so I ran

pipenv install requests

but this returned

'pipenv' is not recognized as an internal or external command,
operable program or batch file.

I have added the path

C:\Users\Robert\AppData\Roaming\Python\Python35\site-packages

to my Windows path environment variable, but I still receive the same error. How can I install the requests package using pipenv?


EDIT: As I have remnants of Python 3.5 and Python 3.6 on my system, I'm going to uninstall everything and start anew. (I've just started learning Python and I want to keep this as simple as possible.)

14

There are 14 answers

2
Dharmesh Fumakiya On

Please check that pipenv is installed in your system by run following command in command promt:

pipenv --version

If it returns error, so please install again and set environment variable path in your system

0
ehacinom On

Windows is not officially supported, I think.

ref: https://github.com/kennethreitz/pipenv/issues/70

4
Tadhg McDonald-Jensen On

python -m pipenv may work for you, (or python3 -m pipenv or py 3 -m pipenv) this is telling python to run the module pipenv instead of the terminal shortcut which requires python's script /bin folder to be on your terminals PATH variable which often the installer gives a warning that no one pays attention to it.


Just to show they are equivalent when I installed pipenv and run which pipenv it points to a file like /Library/Frameworks/Python.framework/Versions/3.6/bin/pipenv which looks like this:

#!/Library/Frameworks/Python.framework/Versions/3.6/bin/python3.6

# -*- coding: utf-8 -*-
import re
import sys

from pipenv import cli

if __name__ == '__main__':
    sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0])
    sys.exit(cli())

so it removes .pyw or .exe from the executable name then call pipenv.cli.cli(). It is likely there is a file like this on your machine it just didn't add python's /bin folder to your system PATH so it isn't accessible. (and you almost certainly were given a warning at some point but it wasn't sufficiently noisy for your attention level)

the module pipenv.__main__ which is run when using python -m pipenv looks like this:

from .cli import cli

if __name__ == '__main__':
    cli()

Which calls pipenv.cli.cli(). So this main module absolutely does the same effective thing.

1
Serzhan Akhmetov On

Try adding the following to Path environmental variable:

C:\Users\Robert\AppData\Roaming\Python\Python36\Scripts

instead of the \site-package, as that is where pipenv.exe is installed (at least for me).

12
Srivats Shankar On

I have a similar setup and faced a similar problem, but the solution I found was fairly simple. All of my PATH variables were already correct (from Python 3 the Windows Installer automatically does all of this).

The problem

The problem actually arises because of conflicting installations of virtualenv.

Fix

To address this problem you need to simply run the following commands:

  1. First, remove your current version of virtualenv: pip uninstall virtualenv

  2. Then, remove your current version of pipenv: pip uninstall pipenv

  3. When you are asked Proceed (y/n)? just enter y. This will give you a clean slate.

  4. Finally, you can once again install pipenv and its dependencies: pip install pipenv

This will also install the latest version of virtualenv.

Testing if it worked

Just enter pipenv --version in the command prompt and you should see the desired output.

Notes

I know this sounds the mundane, but it is actually the solution for Windows systems. You do not need to modify any of your system environment variables (please do not add site-packages to your environment variables).

0
axkirillov On

Instead of

C:\Users\Robert\AppData\Roaming\Python\Python35\site-packages

it should be

C:\Users\Robert\AppData\Roaming\Python\Python36\Scripts

after that, try closing and reopening the terminal

0
Sojimaxi On

I noticed several different situations with multiple python versions installed.

A preferred solution would be to use:

python -m pip install pipenv

This command for Python3.7 instance generates executables in C:\Users\XXX\AppData\Local\Programs\Python\Python37\Scripts and it made setting up other packages easier.

0
Ousseynou Diop On

to solve this problem i need to start my CMD as administrator.

  1. pip uninstall pipenv

  2. pip install pipenv

To test this new configuration, you can write pipenv --version

0
densteam-io On

Many thanks to @Srivats Shankar. In case you have tried what he said and it did not work, hope you did not forget to check your python path? If you have more than a single python version installed, doing pip uninstall virtualenv or pip uninstall pipenv might not help solve the problem.

Every python version is generally supposed to have its own pip installed. What you would do in this case is:

`-python -version_to_uninstall_virtualenv_from -m pip uninstall virtualenv; py --version -m pip uninstall virtualenv
-python -version_to_uninstall_pipenv_from -m pip uninstall pipenv; py --version -m pip uninstall pipenv`

Then you install pipenv with a similar command:

 `-python -version_to_install_pipenv_on -m pip install pipenv; py --version -m pip uninstall pipenv`
0
ProjectAlice On

Use python -m pipenv instead of just pipenv, it should work. Best of luck to you.

1
Rohit Chaurasiya On

use this cmd solve my problem :

python -m pipenv install django==2.1
0
user13492560 On

check warnings after installing pipenv. sometimes pipenv location not registered in environment variables.

0
Erfan Ebrahimi On

I had an error like you sed and I just reinstalled pipenv and it fixed. I used this command:

pip install pipenv
0
Ankit Kumar On

you should use

python -m pip install pipenv

and then

python -m pipenv install requests