Pip.exe from Python on Windows 10 - python

I installed the latest version of Python from www.python.org. Python 3.4.3. I then go to run pip and I get
"Fatal error in launcher: Job information querying failed"
Searching for this error message points me to similar issues running Python under wine. If you grab a pre-compiled pip.exe it will work but it seems that when you install, the pip.exe is generated as part of the installer and this pip.exe does not work.
Further I am dealing with a build script that creates a virtual python environment that uses pip.exe and results in the same error. Not sure how to fix this. Also not sure how pip.exe is generated.

You can use python -m pip install package

Worked for me in windows 10, make sure that you have added python in path of system environment variable. If you are able to run python from powershell then it means python is added to your path. After that you may try using following to upgrade pip
python -m pip install -U pip

Related

Terminal can't find version of python despite it being installed

I'm trying to install packages on multiple versions of Python. I'm currently running 3.8.8, and 3.11.0.
Following this post Install a module using pip for specific python version
called
python3.11 -m pip install pandas
which results in
File "<stdin>", line 1 python3.11 -m pip install pandas SyntaxError: invalid syntax
This seems to indicate an issue with python, so I double checked that python3.11 is installed.
the python3.11 works in isolation seems to work.
I don't understand why the install command isn't working.
If you’re using Linux try just
python3 —-version
In Windows you may need to add path to folder with installed Python to PATH variable.
Check your environment variables, you could try removing the variables pointing to the 3.8 version until you get the packages you want installed.
You could also try navigating to that python 3.11 installation directly, and executing the python shell from there, then run the command.

Why do I have to use "py" to execute python commands instead of "python"?

I am a newbie in Python and had a problem with installing Python packages on my windows computer.
I installed Python itself and then had to install the packages "Numpy" and "Matplotlib" as well. My teacher told us to do it with the commands:
python -m pip install --upgrade pip
pip install numpy
pip install matplotlib
I managed to install Python but when I run the first command to install pip I got the error message telling me that Python is not found. I found the command py -m pip --version here and it worked. After running it pip got installed and I got the message "pip 22.3 from C:\Users\Kaja\Programs\Python\Python310\lib\site-packages\pip (python 3.10)". I guessed this message means that its working.
I had a similar problem with the commands to install Numpy and Matplotlib. It only worked with this commands
py -m pip install numpy
py -m pip install matplotlib
I searched the internet and found this question telling me to run the command doskey py=python and it did not work. But when I swapped py and python so that the command was doskey python=py I eventually could run my teachers commands.
I checked the windows documentation and they are using the same commands as my teacher. I am very curious to know why I had this problem because on my fellow students computers it worked without the doskey command.
Edit:
Thank you very much #RustyPython.
I checked my environment variables and the path to the python.exe was already there.
Out of curiousity I deleted the python.exe from the path variable and although I did that the commands still worked! Another thing I tried was to remove the doskey macro like discribed in this article but still the commands still run without any errors.
I think its something else.
When you install python on windows it usually comes with the python launcher. This provides a way to easily access all the python versions installed on your computer.
The python launcher uses the py command which access the default python version.
py -0p will show you all the installed versions.
See https://www.infoworld.com/article/3617292/how-to-use-pythons-py-launcher-for-windows.html for more details.
For the python command to work then the relevant directory containing python.exe needs to be added to your user PATH variable.
As has been said looks the the python directory is not on your PATH, but the python launcher is and finds the installed python.exe.
If you want python to work on command line then you'll need to add it to your PATH variable. https://realpython.com/add-python-to-path/#how-to-add-python-to-path-on-windows

What is the difference between installing a package in my Windows CMD and in VS Code terminal?

I am doing this project where i need to install a package called Twint.
I want to install this package and use it's commands in my VS Code.
What happends when i for example type this in my Windows CMD?
pip3 install --user --upgrade git+https://github.com/twintproject/twint.git#origin/master#egg=twint
Because i can't type this in my VS code terminal, where i usually install packages with pip.
It will return an error that says ERROR: Cannot find command 'git' - do you have 'git' installed and in your PATH?''
Now if i run this in my Windows Command it seems that i can't directly import the package in VS code?
Can anyone help me out with this confusion, where does the files get stored and how do i create good habbits around installing packages?
Hope someone understands what im struggeling with here.
Best
It is often the case that computers have more than one version of python installed and that editors like VS code use a different version than pip uses on the command line. pip installs packages where the version of python it is linked to expects them to be, but VScode doesn't know to look there.
It sounds like you have git installed where pip installs things, so you can upgrade from the command line without issue, but there's no installation of git where VScode is looking, so there's nothing to upgrade.
You either need to find where pip installs things and add it to the $PATH VScode uses, or try running a variation of python -m pip install --user git (specifying a specific url, or other things, as needed) from within VScode, which will ensure the package gets installed in a place that VScode looks for packages.
Download and Install git in your windows from here:
https://git-scm.com/download/win
Then add its installation bin path to your windows's environment path. Then you will find the git command at the command prompt globally.
This may solve you problem.

Setting up Pip on Windows

I have explored many other questions about the installation of pip on Windows. However, I have had no luck.
I have seen for Python 3.4+ that pip comes with it. I can see pip in the site-packages folder, but trying to run pip -V I get a ModuleNotFoundError.
I successfully added python to the PATH. I then downloaded the get-pip.py file and ran. I made cure to add C:.../Scripts to PATH. Again I tried pip -V and had the same issue.
Also tried python -m pip -V as suggested in the comments and got this error:
C:\Users\apowell\Documents\python-3.7.4-embed-amd64\python.exe: No module named pip
I'm a little lost now on how to successfully use pip. Any help would be appreciated.
EDIT:
For further details, I am doing this all on a virtual machine. I have python/pip all set up on my local machine. What would be the process for copying from my local machine to the VM?
Looks like you are using the embeddable package. It is not meant to be used as is. You should probably try installing Python with the full installer instead. Here is the full installer for Python 3.7.4 Windows 64 bits.

Issue installing pip and pandas

I am trying to install Pandas with Pip and am running into some strange issues. Command prompt reported that pip is an unrecognized command. I thought that was strange, but decided to definitively remedy that by installing pip with the following commands:
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
python get-pip.py
I received the report that an existing version of pip was found, uninstalled, and the new version was installed. I then proceeded to run
pip install pandas
And I was informed that 'pip' is not recognized as an internal or external command, operable program or batch file.
I then added to the path environment and the issue is still persisting. It's worth noting that I installed Python 3.6 by installing Anaconda. What am I missing here?
The pip command is not found because it's not in your path.
You should add the following to your PATH environment variable:
;%PYTHON_HOME%\;%PYTHON_HOME%\Scripts\
A simple Google search should help you find how to change environment variables for you version of Windows.
For example, see this page from the Java documentation.
Try the following
C:\Users\Username>cd C:\Python27\Scripts
C:\Python27\Scripts>pip freeze
If you're using a different Python version, replace Python27, with your version of Python.
On windows you can use !pip install pandas in your Python program without having to open the windows/anaconda prompt.
But as others said, pip is not in your active directory and you would have to open the anaconda prompt or go to the library where pip is installed

Categories