Cannot run pipenv after successfully installing it - python

I know this has been asked before and I reviewed the previous posts, but none of those solved my issue.
I'm new to programming so I may get the terminology mixed up but I will try to explain in as much detail as I can.
I am running Python 3.8 on Visual Studio Code. I installed pipenv successfully:
python -m pip install pipenv
Then I try to actually use it and get this error:
pipenv shell --python 3.8
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 --python 3.8
+ ~~~~~~
+ CategoryInfo : ObjectNotFound: (pipenv:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
During installation I got this warning:
WARNING: The script f2py.exe is installed in 'C:\Users\user\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\Scripts' which is not on PATH.
Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
However, I don't actually know how to do this or even if I should, because I get this warning with every package I install but it works fine anyway.
I am following this tutorial:
Video Tutorial
and the guy specifically says to run the pipenv commands in the directory where our project is, which I am doing and I get this error. Nevertheless I tried to cd to the directory where the pipenv installed and same error.
I am on Win 10 btw. What am I doing wrong?

You may need to add pipenv to you path variable. Check out the note section in the docs. It actually describes how to get the right location to add on Windows:
On Windows you can find the user base binary directory by running
python -m site --user-site and replacing site-packages with Scripts.
For example, this could return
C:\Users\Username\AppData\Roaming\Python36\site-packages so you would
need to set your PATH to include
C:\Users\Username\AppData\Roaming\Python36\Scripts. You can set your
user PATH permanently in the Control Panel. You may need to log out
for the PATH changes to take effect.
That should get it recognized by your terminal.
The last sentence of that reminds me (it's been a while since I used Windows) -- have you tried to restart or logout? I'm not sure if that's necessary to be honest but I know sometimes it is.
Long story short (and only since you mentioned that you are new to programming) -- the "path" lists all of the locations that are accessible to execute from. You can add to it if you want to be able to execute new programs, like pipenv.

This is what solved the issue for me (Windows 10):
I added the correct Scripts folder of the Python version I am actually running. In my case this was C:\python\Scripts. I added that in Control Panel - search "environment" - Edit environment variables (both for my account and system-wide - did it on both places just to be sure, maybe redundant) - Path - Edit - added the path and now the issue is solved. Thank you!!! –

Related

Having trouble running django on Pycharm

I'm sure you guys have heard enough of these questions but I am a new programmer looking to start using Django. I have done pip install django and by the time it's almost done download I received a warning.
WARNING: The script django-admin.exe is installed in 'C:\Users\bryan\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\LocalCache\local-packages\Python37\Scripts' which is not on PATH.
Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
I have ignored this earlier and ran the command django-admin startproject and of course I receive another error.
The term 'django-admin' is not recognized as the name of a cmdlet, function, script file, or
operable program.
Not quite what to do. I need your help. Or at least direct me to a post similar to this matter. Thank you!
I have tried redirecting the PATH with
pip install--install-option="--prefix=C:\Users\bryan\PycharmProjects\mySite" django
I saw this on another post and thought it would help but nothing really worked.
It looks like you have globally installed Python with locally installed Python packages.
Option 1: try doing what Windows says: add the directory with locally installed Python packages to the Windows PATH.
Option 2: consider using virtual environments: https://docs.python.org/3/library/venv.html

Getting error in VS code when trying to create virtual environment on windows

I am trying to create a virtual environment in VS code to make a flask app. After I run the command in the VS code terminal pip install virtualenv everything downloads find but I get the error WARNING: The script virtualenv.exe is installed in
C:\Users\NAME\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\Scripts' which is not on PATH.
Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
Then when I try to create my virtual environment by using this command virtualenv env I get the error
virtualenv : The term 'virtualenv' 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.
Are you using Python from the Windows Store? You'd better avoid it.
You can download the python from the official site.
And then create the virtual environment through venv.
You can refer to official docs for more details of the virtual environment created.
This is happening because the directory (as mentioned by you)
C:\Users\NAME\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\Scripts' which is not on PATH.
is not added to your PATH
Consider this link Add to the PATH on Windows 10 and add the directory to the PATH.
It's gonna solve your problem.
The same issue happened to me it solve it as said above.

Python does not run command

I am trying to run a simple command in a .py file on Visual Studio Code, namely:
import os
I get the following return in the terminal:
& : The term 'C:/Users/Tim-S/anaconda3/envs/plotlyenv/python.exe' 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:3
+ & C:/Users/Tim-S/anaconda3/envs/plotlyenv/python.exe "c:/Users/Tim-S/ ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (C:/Users/Tim-S/...yenv/python.exe:String)
[], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
Can anyone explain me how I can solve this?
Start by installing Python from python.org or choco. Then, in your terminal (cmd, powershell, windows terminal, etc.), run python. Only then, should you attempt to run anything in VS Code.
You may already be having success up to that point, but it isn't clear from your question. I can see you have some environment (anaconda) installed. There are several VS Code plugins for Python. This answer may help you further with that part.
Here is the Windows port of pyenv, which is an excellent version management tool, which may also be of use.
Are you trying to create a virtual environment: by the looks of the path in the error - 'C:/Users/Tim-S/anaconda3/envs/plotlyenv/python.exe'
seems like you are trying to do so. IF that's the case:
Possible it did not get installed properly and hence cannot find the python file
you have to reinstall it and activate the environment
But that will solve the problem partially
After activating virtual environment, you have to install the library
that you are going to use
What I can see from your problem statement and file path you will need to install os and plotly
pip install os
pip install plotly - if required

Can't run python on powershell

When I type python in PowerShell I get an error like:
Program 'python' failed to execute: The system cannot find the file specified
At line:1 char:11
+ python.exe <<<< .
At line:1 char:1
+ <<<< python.exe
+ CategoryInfo : ResourceUnavailable: (:) [], ApplicationFailedException
+ FullyQualifiedErrorId : NativeCommandFailed
I have added C:\Python27 and its sub directories to PATH. I can run it by typing python.exe. Can run scripts the same way.
I installed Python 2.7.11 64 bit.
The only way I can reproduce your error is if I replace my python.exe file with a new empty text file named python.exe.
First Steps
I notice you mentioned that you added C:\Python27 and all subdirectories to your PATH. I would first suggest to remove all the subdirectories (just leaving the parent directory) from your path. Make sure you restart Powershell after making this change to pull in the new values. Then test it to see whether this has resolved the issue.
Alternative solution
The other possibility is that somewhere on your path you have either a corrupted python.exe or some other cmdlet, function or script file that is shadowing your python installation. You could try running from within powershell:
Get-Command python | Select-Object -ExpandProperty Definition
to see what powershell is actually referencing.* If the only value returned is C:\Python27\python.exe then I would probably suggest a reinstall.
Notes:
[*] - Taken from https://stackoverflow.com/a/16949127/1468125
I ran into this problem recently. To fix it, I had to edit the PATH environment variable to ensure my installed location of Python 3 came before C:\cygwin64\bin, which has a softlink of python to an older version.
Technically one could also launch the Cygwin install utility and remove the older python to fix it as well.
However all I did was to right click on the My Computer icon, select properties, then clicked on Advanced systems settings in order to open the Windows System Properties dialog. From there I selected the Environment Variables button. Then I saw, again in my case, that C:\cygwin64\bin was listed in the PATH environment variable twice, once in the user variables section and also once in the System variables section. I re-ordered Python38 to be first in my user variables PATH environment and deleted the C:\cygwin64\bin entry from the System variables PATH environment. Then clicked OK and opened a new Terminal in VS code, and all is good.

python not recognized in Windows CMD even after adding to PATH

I'm trying to -learn to write and- run Python scripts on my Windows 7 64 bit machine. I installed Python in C:/Python34, and I added this to my Windows' PATH variable :
C:\Python34; C:\Python34\python.exe
(the second one is probably meaningless but I tried) and still I get this error in Windows command line :
C:\Users\me>python test.py
'python' is not recognized as an internal or external command,
operable program or batch file.
So how do I truly install Python on my Windows x64 machine ?
This might be trivial, but have you tried closing your command line window and opening a new one? This is supposed to reload all the environment variables.
Try typing
echo %PATH%
into the command prompt and see if you can find your Python directory there.
Also, the second part of your addition to the PATH environment variable is indeed unnecessary.
I had the same problem: python not being recognized, with python in the path which was was not truncated.
Following the comment of eryksun in yossim's answer:
Also, if you installed for all users you should have %SystemRoot%\py.exe, which >is typically C:\Windows\py.exe. So without setting Python's directory in PATH >you can simply run py to start Python; if 2.x is installed use py -3 since >Python 2 is the default. – eryksun
I tried to use py instead of python and it worked.
Meaning:
python setup.py build -> does NOT work.
py setup.py build -> does work.
Hope it helps
I was also having the same problem.
Turns out the path I added included '..\python.exe' at the end, which as turns out was not required. I only needed to add the directory in which 'python.exe' is in (which in my case is the Anaconda's distribution directory in Users folder), similar to what we do when installing JDK in our system's PATH variable.
Hope it helps!
It wasn't working for me even after adding the path. What finally did the trick, was changing the order of listed paths in the PATH variable. I moved %USERPROFILE%\AppData\Local\Microsoft\WindowsApps down vs. having it the first path listed there.
Environment PATH Length Limitation is 1024 characters
If restarting your cmd window does not work you might have reached the character limit for PATH, which is a surprisingly short 1024 characters.
Note that the user interface will happily allows you to define a PATH that is way longer than 1024, and will just truncate anything longer than this. Use
echo %PATH%
in your cmd window to see if the PATH being truncated.
Solution
Unfortunately, there is no good way to fix this besides removing something else from your PATH.
NOTE: Your PATH = SYSTEM_PATH + USER_PATH, so you need to make sure the combined is < 1024.
I did everything:
Added Python to PATH
Uninstall all the Pythons - Both from downloaded python.org and Microsoft Store and reinstall from python.org
Change the order of PATH
Deleted %USERPROFILE%\AppData\Local\Microsoft\WindowsApps from PATH
But nothing worked. What worked for me was:
Settings > Application > App execution aliases. Then disable all the Pyhtons from here and it worked!
Also, make sure to leave no spaces after the semi-colon.
For example, this didn't work for me:
C:\Windows\system32; C:\Python27; C:\Python27\Scripts;
But, this did:
C:\Windows\system32;C:\Python27;C:\Python27\Scripts;
I'm late to the game here, but I'd like to share my solution for future users. The previous answers were on the right track, but if you do not open the CMD as an administrator, then you will be thrown that same error. I know this seems trivial and obvious, but after spending the past 8 hours programming before attempting to install Django for the first time, you might be surprised at the stupid mistakes you might make.
I have faced same problem even though my path contains 400 characters.
Try to update the path from the command line(Run as administrator)
Command to update path: setx path "%path%;c:\examplePath"
After this command I could see that paths that I configured earlier in environment variables got updated and working.
To check the configured paths: echo %PATH%
I was facing similar porblem. What helped me is where command.
C:\WINDOWS\system32>where python
C:\Users\xxxxxxx\AppData\Local\Microsoft\WindowsApps\python.exe
C:\Program Files (x86)\Microsoft Visual
Studio\Shared\Python39_86\python.exe
On updating PATH variable to point to only one desired directory (basically I removed %USERPROFILE%\AppData\Local\Microsoft\WindowsApps from PATH) fixed my problem.
I had the same issue with Python 2.7 on Windows 10 until I changed the file path in Enviroment Variables to the folder path, ie C:\Python27\python.exe didn't work but C:\Python27\ did work.
For me, installing the 'Windows x86-64 executable installer' from the official python portal did the trick.
Python interpreter was not initially recognized, while i had installed 32 bit python.
Uninstalled python 32 bit and installed 64 bit.
So, if you are on a x-64 processor, install 64bit python.
I tried it multiple times with the default installer option, the first one, (Python 3.7.3) with both 'add to environment variable' and 'all users' checked, though the latter was greyed out and couldn't be unchecked.
It failed to work for other users except for the user I installed it under until I uninstalled it and chose "Custom Install". It then clearly showed the install path being in the C:\Program Files\Python37 directory when it was failing to install it there the other way even though the 'All Users' option was checked.
Same thing was happening with me when i was trying to open the python immediately with CMD.
Then I kept my in sleep mode and started CMD using these Key Windows_key+R, typed cmd and OK. Then the package of python worked perfectly.
Uninstall python and pyqt
Then go to pyqt setup and open installation but don't install. You will see a message box saying something like pyqt version built with python version 32bit/64bit.
Then see python version bit and download that version from python.org from all release menu.
Then first install python and then install pyqt. It will work like butter.
I spent sometime checking and rechecking the path and restarting to no avail.
The only thing that worked for me was to rename the executable C:\Python34\python.exe to C:\Python34\python34.exe. This way, calling typing python34 at the command line now works.
On windows it seems that when calling 'python', the system finds C:\Python27 in the path before it finds C:\Python34
I'm not sure if this is the right way to do this, seems like a hack, but it seems to work OK.

Categories

Resources