pip command does nothing - python

I just installed Python 2.7.10 on windows 10.
I have added my python and pip directory to my PATH like so:
My Scripts folder looks like this:
My problem is, when I type in "pip" in command prompt and press enter absolutely nothing happens, even if I wait several minutes. If I remove the Scripts directory from the PATH variable I just get the error message like "pip not recognized as internal or external command". Python works fine. I have also tried to reinstall both pip and Python but the same problem occurs.
So, does anyone have any idea about why pip does not do anything?
**Edit: ** when I say it does not do anything, I mean the cmd "hangs", like if it is waiting for something to happen. The cursor just keeps on blinking.

One command that is bound to work is writing:
python -m pip install requests
This works because you hand off the script invocation to python, which you know works, instead of relying on the PATH environment variable of windows, which can be dodgy.
Packages like numpy that require c-extensions to be built, will not work with pip unless you have a C Compiler installed on your system. More information can be found in this question.
If you are, as you're saying, unfamiliar with the python environment, then let me assure you, you will have a better day by installing Anaconda.
Anaconda is a completely free Python distribution (including for
commercial use and redistribution). It includes more than 300 of the
most popular Python packages for science, math, engineering, and data
analysis.
Anaconda comes with numpy, of course.

After Python including pip at package, pip commands not work sometimes.
Then you can use pip through python like
python -m pip <pip commands that you want>

Try disabling your virus scanner. If this fixes it, exclude the C:\Python27\ folder from scanning (at your own risk).
I had this same issue: typing pip on the command line just puts the cursor on the next line, and nothing happens. I was sure my PATH system variable had C:\Python27\ and C:\Python27\Scripts\ in it, and I could verify it using echo %PATH% on the command line.
I found that I had to disable my virus scanner (Avast). I excluded the C:\Python27\ from virus scanning, and now everything works. Apparently the scanner is interfering with Python's ability to load the module.

Add the following path or you can also cd to the path and then try pip command, it will work fine.
C:\Python27\Lib\site-packages\pip

I had the same issue after uninstalling my antivirus, which was blocking the script. The issue was resolved.

Related

PYSimpleGUI module not found

I made a program in python which I now wanted to turn into an .exe so that other people at my office, who do not have python or any python skills can use it too. This is not the first time I did this, and I am still working on the same machine, however this time I run into the "module not found" error when trying to execute the exe.
Basically I created a GUI with PySimpleGUI and then followed my own guide from last time, where I created a spec file with pyi-makespec, specifying the paths in which the packages are located. These are two locations: in C:// where python is installed, and in the "venv" folder of my Pycharm project. PYSimpleGUI is located in "venv" but not in "C".
After creating the spec file I create the exe with pyinstaller. It was suggested to use --hidden-import=PySimpleGUI as additional flag, which I did do, but I still got the same error. I also made sure python is added to my PATH, but maybe I did something wrong there? Tha path I used is the one where python is installed: C:\Users\Username\AppData\Local\Programs\Python\Python39\Lib\site-packages is that right?
I am completely stuck and can't find any helpful information. How do I solve this issue? Also important: I do not have admin rights on my computer, so installing stuff is always linked to me having to call the support desk...
If more information about this project is needed, let me know.
Usually, modules not found tend to be the issues with virtual environment. Python uses those venvs as some sort of folders where it stores the Python interpreter and packages installed with pip. If you have an error saying some module is not found, you should either install it on your current environment or switch to the one where ot is already installed. For more details, I recommend you to take a look at this tutorial how to use and setup them.
Additionally, you do not need to compile Python code if you can afford relying on the interpreter installed. If you know your target audience has the interpreter installed (an interpreter is usually shipped with various Linux distributives), then you can just give them your source code or even pycache (.pyc) files that it can interpret as well.
I tried three different things at the same time, one of them seemed to have solved the problem:
1.) update pip with the following commands in the PyCharm Terminal
pip install --upgrade PySimpleGUI
2.) update PySimpleGUI with the following commands in the PyCharm Terminal
C:\Users\Username\AppData\Local\Programs\Python\Python39\python.exe -m pip install --upgrade pip
3.) add python39 to PATH
I checked again and I did have \Python39\Scripts in my PATH, but not \Python39 itself, so I added it. The way to do it on windows is to search for "environment variables" (Umgegungsvariablen in german), edit the "Path" Variable (double click or click and press edit, which opens a new window), then add new Path (mine is C:\Users\Username\AppData\Local\Programs\Python\Python39)
I sort them with Python39 being above Python39\Scripts.
This solved my problem with PySimpleGUI, my program started as expected, but then ran into another missing module error (xlsxwriter not found), which - fair enough - was not imported. (interestingly when running the code in pycharm I didn't need xlsxwriter). I imported it, added it to venv, and when starting the program again, the error showed up even before showing the GUI. I then upgraded xlsxwriter with
pip install --upgrade xlsxwriter
I again created the .spec file and ran pyinstaller to create the exe. This time it worked.
Now I only have issues left which are not connected to missing modules (just variable referenced before assigned).

Why Python and pip can't be found neither on cmd or in IDE?

I messed up with the files and deleted some 32bit Python files because I thought that they're unnecessary.
Then I discover that they had some interesting files to run some specific modules so I just uninstalled Python and re-downloaded it. When I tried to run pip in cmd and even git bash it shows that Python is not defined even after I added it to path same with pip module, now no code can be executed.
import pygame
pygame.init()
screen = pygame.dis`play.set_mode((800, 500))
What shall I do to fix it?
As you not provide the message, that appears when python or pip is not found, all below is just my speculations about the common mistakes in more or less close cases (as I undertand that).
Programs may be not found as they are not in your %PATH%. To ensure that you need to open new CMD window and issue
echo %PATH%
If there is no signs of folder your Python was installed in the output you'll see - that's the case I'm talking about. Otherwise just ignore all the following part of my answer.
In that case one of the easiest way is to properly uninstall Python and then install it once again. Don't forget to mark "Add to PATH" option during install.

PyCharm terminal doesn't recognize Python or Pip

I'm using PyCharm for a project, and I've been having a problem I can't understand. In the "terminal" (in PyCharm), I activate the virtualenv I want, which has Python and all my other packages. The project works, which means the packages are being found, because otherwise it wouldn't work. But the thing is, neither python nor pip are recognized in the PyCharm terminal. This happens whether the virtualenv is activated or deactivated, so I don't think that's the issue.
I get the "python is not a recognized internal or external command" message, but if I do it in the file system, for instance, I can use python, pip, and everything else just fine, so I think it might be a configuration of my PyCharm, most likely, but I don't even know where to look, I don't see anything in the settings that I find odd. Any help could save me a lot of time I've been stuck with this. I'm on Windows 10, by the way.
The environment variable 'PATH' is 'C:\Users\Iván\AppData\Local\Programs\Python\Python36', and python is recognized anywhere but within the PyCharm terminal.
If you are using windows.
You have to add paths to python & pip in environment variables. If you have no previous experience doing so. I would ask to use this link https://www.youtube.com/watch?v=DrhkbjDAUV0.
If I am getting your problem wrong sorry.

Python's uninstllation caused pip to stop working

I have uninstsalled python 3.6, and just installed 3.7. I have tried using pip on cmd, but when doing so I get this message:
Fatal error in launcher: Unable to create process using '"c:\program files\python36\python.exe" "C:\Program Files\Python36\Scripts\pip.exe" '
It seems that pip is still referencing the old python version. I know I can use py -m pip instead, but I really want to use only pip. Any solutions?
OK, the first problem is that the first pip on your PATH is one that got left behind by Python 3.6.
You can find it with where pip, and it will show you… something named pip.exe, in some standard location (like your Windows system directory?) that comes before any of your Python 3.7 directories on the your PATH.
So, find that pip.exe and delete it.
Also, make sure you no longer have the Python 3.6 directories on your PATH. (If you change this in the control panel, you will have to open a new Command Prompt window to see the effects.)
Now, either pip will just work (with 3.7), or it will tell you 'pip' is not recognized as an internal or external command, instead of trying to work with the missing 3.6 and failing.
If you get the "not recognized" error:
Python installers no longer add everything to your PATH by default. Handling Scripts directories from multiple Python installations is a nightmare, especially for novices, and it's easier to recommend everyone use py -m pip and py -m otherscript.
If you don't like that recommendation, and you're experienced enough to either avoid, or properly deal with, multiple Python installations, you can manually manage your PATH to get the old behavior.
The way to do that is pretty simple: just look inside your Python 3.7 directory, see where pip is, and add that location to your PATH.

Install Python package, syntax invalid

I have the familiar problem of not being able to install a Python package, pyautogui; "syntax invalid", with install highlighted:
pip install pyautogui
The explanations I've read are all the same, that this code is to be entered into one of the IDLE windows and not the other. Well I've tried both and the result is the same, syntax invalid.
This is Python 3.4.3 on Windows 7.
As #TigerhawkT3 said in the comments, you are supposed to install from CMD, not the Python Shell. pip is an executable that downloads packages.
As the wikipedia page on pip states:
One major advantage of pip is the ease of its command-line interface, which makes installing Python software packages as easy as issuing one command
So pip needs to be run from the command line.
So how do you use pip?
Since you are on Windows 7 the sure-fire way to run it is to open the start menu, type cmd, and click the first result. Then you will be running command prompt, or CMD for short. I suggest that you run pip -h to display the help for more on how to use pip.
If you have
'pip' is not recognized as an internal or external command,
operable program or batch file.
You need to add the path to your scripts folder (the solution is this SO question).
To take an excerpt, you need to execute
setx PATH "%PATH%;C:\Python34\Scripts".
Note that you need to close and re-open CMD for the change to take effect.
Good luck!
EDIT:
For future reference, if you want to set the environment variable, and Setx isn't working, you should search for Edit the system environment variables. Then go to Environment Variables->(in the second list) Path. Then double click that, and append C:\Python34\Scripts;.

Categories

Resources