Python's uninstllation caused pip to stop working - python

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.

Related

Python conflicts when importing?

I have windows 10 with 2 user accounts, one is an old one that has Python installed. My latest account also has Python installed. I used pip install tweepy, and it now exists in the site packages. If I open my Python shell (v3.6.5), it imports fine. However, I can't get this to work when switching to Python in cmd. In here, after typing python, it says Python 3.6.6. Obviously they are different, yet they seem to be originating from the same directory.
Any ideas?
[edit] I have just realised that I have an external application that runs on Python 3.6.6., so I guess it's defaulting because of that. However, I can't uninstall that since I need it - is there a way to specify which version of Python is launched when I type python into the cmd?
[edit2]: This is the issue, and the solution there works. However, I want to be able to just type python into cmd, rather than the entire path. Since both exist in the path (and I don't want to remove the other 3.6.6.), is there a way to achieve this?
Have you thought about using a virtual environment?
https://virtualenv.pypa.io/en/latest/
When you enter "python" into your cmd it searched python.exe in the directories listed on your PATH variable.
All you need to do is to modify your PATH and add the directory path in which the python with the desired version is located.

I changed "python.exe" to "python3.exe" but now pip returns an error, how can i fix this?

So in order to make my life easier, I changed Python 2.7 to "python2.exe and Python 3.6 to "python3.exe". I then added them to my path and am able to reference them in which python2 opens Python 2.7 and python3 opens Python 3.6.
This is exactly what I want but now since I changed the names the pip command returns this:
Fatal error in launcher: Unable to create process using '"'
I still want to be able to reference python3 and run Python 3.6, but I need pip to work. Do I change a pip file to reference it? or is it something else? Please help if you can.
I strongly recommend you change the names back, because numerous scripts (pip likely included) expect the original filename.
To make your life easier when launching python files on windows, python comes with a more flexible solution. If you have a recent python3 installed on windows, the Python Launcher for Windows should be installed as well. That means you can run python 2 and 3 scripts with a py <file> command. The launcher respects shebang lines specifying the python version or you can pass a flag to choose the version manually: py -2 <file>

pip command does nothing

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.

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;.

Python cannot find module even when path is appended to sys.path

Having some weird troubles installing python modules on my work computer (read: no admin/root rights), I'm using 2.7.5. I downloaded and unpacked the tarball and ran 'setup.py', but it had no effect: When I open the python shell, it can't find the module (this specific one is fuzzywuzzy). However, if I right click -> edit with IDLE the setup.py, and then run the shell from that file, it loads and works perfectly fine. Or, if I then open a new file from that shell, use the module and run it, it works fine. -__-
I've tried using:
import sys
sys.path.append('path here')
to append the location where the module is installed, but this doesn't help, nor does the path stay in the sys.path list when I close/reopen the shell.
This is actually driving me insane. Can anyone help? I'm relatively new to programming and python.
The best and easy way provided by python to install/uninstall packages is to use PIP.
use this
python -m pip install packagename==version
same way to uninstall
python -m pip uninstall packagename==version
if you are using windows you need to set path variable first usually python file will be in path C:\Python27 to set path variable
PATH=%PATH%;C:\Python27;

Categories

Resources