简体   繁体   中英

Pipenv script won't run on Windows using Git Bash

I am running Gitbash for windows and have installed pipenv using pip. Yet when I invoke pipenv nothing happens:

在此处输入图像描述

Since there isn't a command not found error, I believe the script is recognized it just isn't running properly.

Pipenv is installed globally:

在此处输入图像描述

I also can confirm that the Scripts folder is in the file path:

在此处输入图像描述

I don't think it is a problem with Gitbash because I can run other pip packages in the same scripts folder:

在此处输入图像描述

I'm also able to run python pipenv.exe but not pipenv.exe when in the Scripts folder:

在此处输入图像描述

I've struggled with this myself untill just now.
I've got a few suggestions.

SOLUTION 1:
I was calling Poetry to try and make sense of it as well and then I tried calling both applications from Powershell. Both work as inteded.

SOLUTION 2:
Calling python -m pipenv , as sugested in this other Stack Overflow thread , also works as intended. You could alias the command to pipenv in git bash and call it a day too.
Quoting the docs on the -m flag:

When called with -m module-name , the given module is located on the Python module path and executed as a script.

Quoting appdividend.com :

The -m flag in Python searches the sys.path for the named module and executes its contents as the __main__ module.

It goes through whatever path is in which pipenv and executes the module as a script.

SOLUTION 3:
This is how I ended up fixing my Pipenv blunder.
Reinstall Python and all packages to AppData .
MINGW64 was having trouble seeing Pipenv in C:\Program Files . I also noticed that I had some packages in AppData\Roaming as well, so I figured I'd reinstall Python, unticking the Install for all users option (to trigger AppData installation) to see if I could wrangle all packages together.
After that I tried installing Pipenv and succeeded in calling it as expected.

This is all highly anecdotal. I have no idea why MINGW64 failed to call JUST Pipenv and not Poetry, but this is how I've fixed it on my end.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM