Can't install kivy. Fail Building wheel for kivy (pyproject.toml) - pip

I've somehow screwed up either my pip or my kivy files. I cant install either. I've tried pip install kivy and also git clone https://github.com/kivymd/KivyMD.git --depth 1
I'm on a macos Monterey 12.6.1
python 3.11`
I start with:
$ python3 -m venv venv
$ . venv/bin/activate
$ pip install kivy
It gets hung up on the building wheel for kivy pyproject.toml.
Requirement already satisfied: certifi>=2017.4.17 in ./myvenv/lib/python3.11/site-packages (from requests->Kivy-Garden>=0.1.4->kivy) (2022.9.24)
Building wheels for collected packages: kivy
Building wheel for kivy (pyproject.toml) ... -
Then the end of the error code looks like:
kivy/core/image/img_imageio.c:438:62: note: expanded from macro '__Pyx_PyFrame_SetLineNumber'
#define __Pyx_PyFrame_SetLineNumber(frame, lineno) (frame)->f_lineno = (lineno)
~~~~~~~^
/Library/Frameworks/Python.framework/Versions/3.11/include/python3.11/pytypedefs.h:22:16: note: forward declaration of 'struct _frame'
typedef struct _frame PyFrameObject;
^
2 warnings and 1 error generated.
error: command '/usr/bin/clang' failed with exit code 1
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
ERROR: Failed building wheel for kivy
Failed to build kivy
ERROR: Could not build wheels for kivy, which is required to install pyproject.toml-based projects
(
I'm at a complete lost. I've tried to uninstall and reinstall packages, I've done pip install wheel , and pip install clang both recommended from other SO posts.

I had the same problem so I asked on the Kivy Discord and I was told that there is no wheel for kivy on Python 3.11 yet.
I was told to build it from source and that worked.
https://kivy.org/doc/stable/gettingstarted/installation.html#kivy-source-install
git clone https://github.com/kivy/kivy.git
cd kivy
python3.11 -m pip install cython
python3.11 setup.py build_ext --inplace
make install
It is best to do this in a virtual environment
python3.11 -m virtualenv <Environment Name>
cd <Environment Name>
source bin/activate

Right now, February 2023, there are two alternatives to this problem in macOS. Possibly works the same for Windows, I don't know. The first is shown above and can be described as "building your own wheel" for Python 3.11. That approach did not work for me as my installation crashed at the "make install" line with error messages about xcode. The second alternative, which worked for me, was to install the most recent version of Python for which Kivy already had a wheel buuilt. In my case, I installed Python3.10. After i installed Python3.10, the Kivy installtion instructions at www.kivy.org worked flawlessly.
Python 3.10 has a installer package at www.python.org so its easy to install. In my case, the installer package modified my .bash_profile file so that python3.10 was inserted into my PATH.
In my case, Python3.10 was the most recent version of Python installed on my machine. If Python 3.10 is not the most recent version on your computer, then you may encounter problems. Different applications on your computer may use different releases of Python. The Python installer may change your PATH variables to point only at the Python 3.10 installation.
I suspect that the "build your own wheel" issue is common with Kivy installtions because Kivy always lags behind Python. Python will release Python 3.12 and it will be a while, months I would guess, before Kivy catches up. So that means if you keep your Python install always up-to-date then you will center encounter the need to "build your own wheel".

Related

How can I solve this installation problem with fastavro on Mac?

I am trying to run in my Mac a Python program which requires working with .avro binary files.
Despite trying to install it by using: pip install fastavro, I always get an error message on the terminal that ends with the following lines:
...
xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun
error: command '/usr/bin/clang' failed with exit code 1
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
ERROR: Failed building wheel for fastavro
Failed to build fastavro
ERROR: Could not build wheels for fastavro, which is required to install pyproject.toml-based projects
I have updated conda to its latest version on my PC as well as updated pip as well.
Does anyone know how to solve this? I really need to run this program on Mac as soon as possible. For your information, I am able to install and use fastavro on Windows but not on Mac so this is likely to be a Mac-specific problem.
Thanks a lot
Since you are working in a conda environment, why not install it with conda? I often find installations via conda much more convenient since it takes care of all non-Python dependencies as well.
So try uninstalling the package first with pip: pip uninstall fastavro and then installing it via conda: conda install fastavro -c conda-forge.
In case you are unfamiliar with the -c conda-forge flag, it tells conda to look for the package on the conda-forge channel which has almost all packages that are not available via the standard channels.

Message "note: This error originates from a subprocess, and is likely not a problem with pip"

While downloading pip install allennlp==1.0.0 allennlp-models==1.0.0, I faced this problem:
[6 lines of output]
running bdist_wheel
running build
running build_py
running build_ext
building 'srsly.msgpack._unpacker' extension
error: Microsoft Visual C++ 14.0 or greater is required. Get it with "Microsoft C++ Build Tools": https://visualstudio.microsoft.com/visual-cpp-build-tools/
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
ERROR: Failed building wheel for srsly
Failed to build thinc blis srsly
ERROR: Could not build wheels for srsly, which is required to install pyproject.toml-based projects
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
error: subprocess-exited-with-error
× pip subprocess to install build dependencies did not run successfully.
│ exit code: 1
╰─> See above for output.
note: This error originates from a subprocess, and is likely not a problem with pip.
I have downloaded:
pip install -vvv torch
pip install numpy
pip3 install --pre torch -f https://download.pytorch.org/whl/nightly/cpu/torch_nightly.html
and it still not working.
I am using Python 3.10.2 on Windows 11 Pro.
What should I do?
I had Python 3.10 and had the same error installing psutil from pip. I fixed the problem by installing an older version of pip using the command:
pip install pip==21.3.1
You have to install the Python 3.9.10 version from python.org and after installation, upgrade your pip and everything will be sorted.
It is the problem in Python 3.10.2... This method is working. I was suffering from the same problem in installing the turtle, so I did that and error was solved.
This particular error is caused by not having a C/C++ compiler installed. As said in the error message, either install MSVC or another compiler to compile it.
Please read your error messages; they are there for a reason.
If you're using a Python 3 image, this might help:
RUN apk update
RUN apk add make automake gcc g++ subversion python3-dev
Reference from Problems with pip install numpy - RuntimeError: Broken toolchain: cannot link a simple C program
https://visualstudio.microsoft.com/visual-cpp-build-tools/
Download and install or update
Microsoft Visual C++ 14.0 or greater is required.
You must be install build visual tools 15, 17, 19, or greater.
Download from Microsoft C++ Build Tools.
To solve this problem, you need to download Visual Studio from its main page.
If Visual Studio is already installed, then when you run the installer, you can modify it (by clicking the modify button):
During Visual Studio installation (or installation modification) choose Desktop Development with C++:
First: You installed the Mingw-w64 compiler with a full MSYS2 package, and this package included Python.
Second: you get the error because the plugin is not in the Python packages installed by MSYS2.
So: uninstall MSYS2 and install a minimalistic MinGW (MinGW - minimalistic GNU for Windows).
And finally Install a version of Python from the official Python page.
Now if you can install plugins.
I've found a similar question from GitHub, and credits goes to thaibee. Here I quote:
It's a problem with Microsoft products and is
very easy to solve.
If you can't install these plugins as well,
need to download it from other repositories like this one:
https://www.lfd.uci.edu/~gohlke/pythonlibs/ depends on the version of python and the system.
For example: for my Windows 11 (x64) and Python 3.10 I took this file: pyodbc‑4.0.32‑cp310‑cp310‑win_amd64.whl
It's very easy to install: pip install pyodbc‑4.0.32‑cp310‑cp310‑win_amd64.whl
After it, the system works well and didn't ask you about VC.
This solution I found in problem with the MySQL plugin for Django. I don't understand why - but they also use VC for the installation process.
I understand your problem, and I have faced it too. I tried multiple solutions, but it didn't work, so I simply uninstalled my Python and installed some older version of it. Example: I recently uninstalled Python 3.10.2 and installed 3.9.10.
It worked without any errors.
I had a similar problem while installing with pip3: building wheel for box2d-py (setup.py) ... error
The solution was just to install SWIG prior to box2d, so I added the following steps manually:
pip install swig
pip install gym[box2d]
For Mac, there is a possible workaround for this problem if you use Conda. The idea is to create an x86 environment on the Mac and do your pip install after that.
conda create -n <name>
conda activate <name>
conda config --env --set subdir osx-64
conda install python=3.8
Here I choose Python 3.8, but you can choose another version.
If you are on macOS (maybe Apple silicon) then first try to do this from your base location of the terminal:
eval "$(/opt/homebrew/bin/brew shellenv)"
Then, do brew update and brew upgrade.
Once you are done with that, type
brew install geos
Now again go to your virtual environment and activate it (if you are working in the virtualenv) and then type:
python3.10 -m pip3 install [module name]
I was facing the same problem when executing:
python -m pip install package-name
After many failed tentatives, what fixed the problem for me was executing:
py -m pip install package-name
When I type py in the terminal, it shows this information:
Python 3.9.8 (tags/v3.9.8:bb3fdcf, Nov 5 2021, 20:48:33) [MSC v.1929 64 bit (AMD64)] on win32
When I type python in the terminal, it shows this information:
Python 3.8.2 (default, Apr 9 2020, 13:17:39) [GCC 9.3.0 64 bit (AMD64)] on win32
I believe that this problem is related to the Python interpreter version.
I tried all recommendations that were written, but none worked. My Python was 3.11.
So I just installed Python 3.8.10 from here:
https://www.python.org/downloads/release/python-3810/
And ran
C:\Python38\python.exe -m pip install matplotlib
And it worked.
I faced a similar problem while installing pandas-datareader.
I was using Python 3.11.0, and after trying all possible solutions, I downloaded Python 9.10.0 and it worked fine.
We can install DVC with the below commands:
conda install -c conda-forge mamba # installs much faster than conda
mamba install -c conda-forge dvc
For more information please refer this: https://dvc.org/doc/install/

Installing PySide on Mac: is there a working method?

I may be doing something wrong, but I have been trying to install pyside on Mac 10.12 (Sierra). Here is what I tried (after installing Qt with brew):
With the precompiled package (1.2.1); fails because of "incompatible package".
With sudo -H pip install pyside (1.2.4): fails with the following error:
Qt QTGUI library not found.
Qt QTXML library not found.
Qt QTCORE library not found.
CMake Error at ApiExtractor/CMakeLists.txt:82 (qt4_add_resources):
Unknown CMake command "qt4_add_resources".
With brew install pyside==1.2.2 : works successfully but when calling it from a python program, fails with ImportError: dlopen(/Library/Python/2.7/site-packages/PySide/QtCore.so, 2): Libmrary not loaded: libpyside-python2.7.1.2.dylib
Referenced from: /Library/Python/2.7/site-packages/PySide/QtCore.so
Reason: unsafe use of relative rpath libpyside-python2.7.1.2.dylib in /Library/Python/2.7/site-packages/PySide/QtCore.so with restricted binary
The last one did offer some hope, and I tried PySide import error Mac OS X El Capitan, Library not loaded: #rpath/libpyside.cpython-34m.1.2.dylib . Unfortunately, the explanation was quite elliptic and I ended up breaking things further.
Am I missing something obvious? The fact that the precompiled packages are old and the web doc is not updated, that brew install does not seem to work (and the documentation makes no mention of it) and generally number of questions asked about pyside and the technical complication of the answers do not seem very good signs.
Does someone know what the matter is with PySide's installation on Mac OS, technically? What's the best solution in my particular case?
More generally, is there hope for improvement with PySide on Mac?
Update (25 Jan 2017): Workaround?
Since we are waiting for an update from Pyside, is someone willing to take the challenge of installing 1.2.2 on OS Sierra with brew, and resolve the "unsafe use of relative path"? Perhaps propose a step-by-step tutorial?
That might save the day for PySide on Mac... while relieving the time pressure on the Pyside development team?
I have MAC osSierra (10.12.6). I needed to install PySide 1.2.4 for Python 3.3.6. I did the following to build and install PySide 1.2.4 that I need. You can do the following for any Python 3.3.x, I guess.
I am a newbie to Mac and Python. Please ignore if I have any mistakes.
Install pyenv
brew install pyenv
Install Python 3.3.6 using pyenv
pyenv install 3.3.6
Add python 3.3.6 into system path
PATH="/Users/myname/.pyenv/versions/3.3.6/bin:${PATH}"
export PATH
Install Xcode from app store, then run the following. Xcode download and install took 30-40 minutes for me.
xcode-select --install
sudo xcodebuild -license
Install cmake
brew install cmake
Verify cmake is installed. I see version 3.10.0 installed
cmake —version
Tap qt4. Note: I tried qt5, but pyside build is not working for me with qt5.
brew tap cartr/qt4
brew tap-pin cart/qt4
Install qt#4.
brew install qt#4
Verify qmake is installed. I see version 2.01a installed
qmake —version
(If qmake is not recognized, create links to it using below command)
brew link cartr/qt4/qt#4 —-force
If you are using “PySide.QtWebKit” in your programs, you need to install qt-webkit. Install pyside (1.2.2 ??), which will install qt-webkit. I am not sure if qt-webkit can be installed directly, if so someone can correct me.
brew install pyside
Download PySide 1.2.4 tar file.
wget https://pypi.python.org/packages/source/P/PySide/PySide-1.2.4.tar.gz
Untar the tar file
tar -xvf PySide-1.2.4.tar.gz
Go into the folder
cd PySide-1.2.4
Build pyside. This build step took almost 30-40 minutes for me
python setup.py bdist_wheel
Verify that “dist” folder is created and it has pyside wheel file in it.
Go into the “dist” folder
cd dist
Instal PySide, last step!!
pip install PySide-1.2.4-cp33-cp33m-macosx_10_12_x86_64.whl
Congratulations!, now you have PySide 1.2.4 for Python 3.3.x
This isn't the answer but unfortunately there has not been any output from pyside team for macOS sierra .Only supported OS from apple are
10.6 Snow LeopardOS X
10.7 LionOS X
10.8 Mountain LionOS X
10.9 MavericksOS X
10.10 Yosemite
Update : (You can try this still )
curl -O https://raw.githubusercontent.com/Homebrew/homebrew-core/fdfc724dd532345f5c6cdf47dc43e99654e6a5fd/Formula/qt5.rb
brew install ./qt5.rb
If above lines doesn't work :
You’ll need the Xcode commandline tools:
xcode-select --install sudo xcodebuild -license
Then the following packages can be easily installed via brew:
brew install qt5 cmake libxslt libxml2
This will install Qt 5.6.1-1 and cmake 3.5.2 your system
Now time to clone ! Not from github but from this link :
So Clone the pyside-setup repository and have it also pull down its gitmodules:
git clone --recursive https://codereview.qt-project.org/pyside/pyside-setup
This command worked fine for people using Python 2.7.11 and Python 3.5.1. Remember to have pip installed with the wheel package or you’ll get an error about bdist_wheel.
python setup.py bdist_wheel --ignore-git --qmake=/usr/local/Cellar/qt5/5.6.1-1/bin/qmake --cmake=/usr/local/bin/cmake --openssl=/usr/local/Cellar/openssl/1.0.2h_1/bin
(Note :
The exact paths given in the arguments may not be identical on your system so verify those prior to compiling)
Install the wheel :
A wheel was hopefully built in the dist folder. So just cd dist and pip install away!
Notes on pre-compiled wheels
Unfortunately, and like with PySide, these wheels are not “portable” and won’t install on systems which doesn’t already have the specific Qt5 version installed used during compilation. This, I believe, is because PySide2 links dynamically (instead of statically) against the Qt5 installation. Hopefully, this is something The Qt Company will address via official PySide2 wheels, as Riverbank Software is now providing a fully portable PyQt5 wheel for Python 3 which is absolutely awesome.
New Repository (not from github)
Reference
The Mac steps from here worked for me: https://fredrikaverpil.github.io/2016/08/17/compiling-pyside2/
You’ll need the Xcode commandline tools:
xcode-select --install
sudo xcodebuild -license
Then the following packages, easily installed via brew:
brew install qt5 cmake libxslt libxml2
Clone the pyside-setup repository and have it also pull down its gitmodules:
git clone --recursive https://codereview.qt-project.org/pyside/pyside-setup
Build it. This command worked fine for me using Python 2.7.11 and Python 3.5.1. Remember to have pip installed with the wheel package or you’ll get an error about bdist_wheel.
cd pyside-setup
python setup.py bdist_wheel --ignore-git --qmake=/usr/local/Cellar/qt5/5.6.1-1/bin/qmake --cmake=/usr/local/bin/cmake --openssl=/usr/local/Cellar/openssl/1.0.2h_1/bin
Last but not least, install the wheel:
cd dist
pip install PySide2-2.0.0.dev0-cp27-cp27m-macosx_10_12_x86_64.whl
All credits go to Fredrik Averpil's wonderful post.
You need a specific version of Qt and pyside.
Install both the QT 4.8.5 package as well as pyside from the Mac installers on the page below:
https://wiki.qt.io/PySide_Binaries_MacOSX
You need QT4 to install PySide on 10.11 (not sure about 10.12).
Install QT5 either via Brew or via installer, get cmake via brew and get the latest PySide source (https://pypi.python.org/packages/source/P/PySide/PySide-1.2.4.tar.gz) Run the following to get Qt4:
brew tap cartr/qt4
brew tap-pin cartr/qt4
brew install qt_4
Once you do so; cd in the source folder and run the following to build:
python setup.py bdist_wheel --ignore-git --qmake=[QMAKE_FROM_QT4_PATH] --cmake=[YOUR_CMAKE_PATH]
cd dist
pip install [YOUR_BUILT_PYSIDE_WHEEL]
Once you do so, you can check that PySide is working correctly, opening a Python console and typing import PySide
I still not have a solution, but I found an alternative.
First of all, I am not an expert (I am super new coding). Based on my own experience below you will find a solution as well.
I need to clarify something first, there are two ways to use this GUI QT - PyQt by Riverbank Computing or(and) PySide, originally developed by Nokia.
I tried many differents ways to install PySide on my MacOS Sierra version10.12.5, but no success, so I ended up finding PyQt, that does the same thing.
Watching this video I installed the PyQT5 in my Mac OS and now it is working. https://www.youtube.com/watch?v=2kHk8ZjxH64
Example of Hello World using PyQT http://pythoncentral.io/intro-to-pysidepyqt-basic-widgets-and-hello-world/
The wiki.qt.io says "PySide has included support for Python 3.2 since version 1.0.8." but it doesn't work for me.
Good lucky.

Can't install psycopg2

I'm trying to install psycopg2 so I can use PostgreSQL in Python and Django. I have run into multiple errors in the last few hours trying to install it, and can't seem to solve the latest one. When I run:
setup.py install
on the psycopg2 in the command console it attempts to install it, but then gives an error when trying to execute link.exe in the Visual Studio 8 folder.
This doesn't make sense to me, considering I got that executable to work when I launch it from Windows Explorer, and from the command console. I even made an environment variable for it. However, it keeps giving:
"error: command C:\Program Files(x86)\Microsoft Visual Studio 9.0\VC\BIN\link.exe" failed with exit status 1120
In case anyone goes down this rabbit hole also, make sure your pip is up-to-date:
$ pip install -U pip
$ pip install psycopg2-binary
See: http://initd.org/psycopg/docs/install.html.
That's 3 hours of my life I won't get back.
Turns out this 3 and a half hour process I've been going through was unecessary. an exe installer of psycopg2 can be downloaded from here
Had the same problem.
Image of the error message
first run
sudo apt install libpq-dev python3-dev
then
pip3 install psycopg2
Go to https://pypi.org/project/psycopg2.
In release history select the version you want to download: there will be a table with files and compatible versions of Python.
Download the binary file that matches your system configuration.
For example, for Python 3.6 on Windows 10 (64-bit) download psycopg2-2.8.6-cp36-cp36m-win_amd64.whl.

How do I install pip on Windows?

pip is a replacement for easy_install. But should I install pip using easy_install on Windows? Is there a better way?
Python 3.4+ and 2.7.9+
Good news! Python 3.4 (released March 2014) and Python 2.7.9 (released December 2014) ship with Pip. This is the best feature of any Python release. It makes the community's wealth of libraries accessible to everyone. Newbies are no longer excluded from using community libraries by the prohibitive difficulty of setup. In shipping with a package manager, Python joins Ruby, Node.js, Haskell, Perl, Go—almost every other contemporary language with a majority open-source community. Thank you, Python.
If you do find that pip is not available, simply run ensurepip.
On Windows:
py -3 -m ensurepip
Otherwise:
python3 -m ensurepip
Of course, that doesn't mean Python packaging is problem solved. The experience remains frustrating. I discuss this in the Stack Overflow question Does Python have a package/module management system?.
Python 3 ≤ 3.3 and 2 ≤ 2.7.8
Flying in the face of its 'batteries included' motto, Python ships without a package manager. To make matters worse, Pip was—until recently—ironically difficult to install.
Official instructions
Per https://pip.pypa.io/en/stable/installing/#do-i-need-to-install-pip:
Download get-pip.py, being careful to save it as a .py file rather than .txt. Then, run it from the command prompt:
python get-pip.py
You possibly need an administrator command prompt to do this. Follow Start a Command Prompt as an Administrator (Microsoft TechNet).
This installs the pip package, which (in Windows) contains ...\Scripts\pip.exe that path must be in PATH environment variable to use pip from the command line (see the second part of 'Alternative Instructions' for adding it to your PATH,
Alternative instructions
The official documentation tells users to install Pip and each of its dependencies from source. That's tedious for the experienced and prohibitively difficult for newbies.
For our sake, Christoph Gohlke prepares Windows installers (.msi) for popular Python packages. He builds installers for all Python versions, both 32 and 64 bit. You need to:
Install setuptools
Install pip
For me, this installed Pip at C:\Python27\Scripts\pip.exe. Find pip.exe on your computer, then add its folder (for example, C:\Python27\Scripts) to your path (Start / Edit environment variables). Now you should be able to run pip from the command line. Try installing a package:
pip install httpie
There you go (hopefully)! Solutions for common problems are given below:
Proxy problems
If you work in an office, you might be behind an HTTP proxy. If so, set the environment variables http_proxy and https_proxy. Most Python applications (and other free software) respect these. Example syntax:
http://proxy_url:port
http://username:password#proxy_url:port
If you're really unlucky, your proxy might be a Microsoft NTLM proxy. Free software can't cope. The only solution is to install a free software friendly proxy that forwards to the nasty proxy. http://cntlm.sourceforge.net/
Unable to find vcvarsall.bat
Python modules can be partly written in C or C++. Pip tries to compile from source. If you don't have a C/C++ compiler installed and configured, you'll see this cryptic error message.
Error: Unable to find vcvarsall.bat
You can fix that by installing a C++ compiler such as MinGW or Visual C++. Microsoft actually ships one specifically for use with Python. Or try Microsoft Visual C++ Compiler for Python 2.7.
Often though it's easier to check Christoph's site for your package.
-- Outdated -- use distribute, not setuptools as described here. --
-- Outdated #2 -- use setuptools as distribute is deprecated.
As you mentioned pip doesn't include an independent installer, but you can install it with its predecessor easy_install.
So:
Download the last pip version from here: http://pypi.python.org/pypi/pip#downloads
Uncompress it
Download the last easy installer for Windows: (download the .exe at the bottom of http://pypi.python.org/pypi/setuptools ). Install it.
copy the uncompressed pip folder content into C:\Python2x\ folder (don't copy the whole folder into it, just the content), because python command doesn't work outside C:\Python2x folder and then run: python setup.py install
Add your python C:\Python2x\Scripts to the path
You are done.
Now you can use pip install package to easily install packages as in Linux :)
2014 UPDATE:
1) If you have installed Python 3.4 or later, pip is included with Python and should already be working on your system.
2) If you are running a version below Python 3.4 or if pip was not installed with Python 3.4 for some reason, then you'd probably use pip's official installation script get-pip.py. The pip installer now grabs setuptools for you, and works regardless of architecture (32-bit or 64-bit).
The installation instructions are detailed here and involve:
To install or upgrade pip, securely download get-pip.py.
Then run the following (which may require administrator access):
python get-pip.py
To upgrade an existing setuptools (or distribute), run pip install -U setuptools
I'll leave the two sets of old instructions below for posterity.
OLD Answers:
For Windows editions of the 64 bit variety - 64-bit Windows + Python used to require a separate installation method due to ez_setup, but I've tested the new distribute method on 64-bit Windows running 32-bit Python and 64-bit Python, and you can now use the same method for all versions of Windows/Python 2.7X:
OLD Method 2 using distribute:
Download distribute - I threw mine in C:\Python27\Scripts (feel free to create a Scripts directory if it doesn't exist.
Open up a command prompt (on Windows you should check out conemu2 if you don't use PowerShell) and change (cd) to the directory you've downloaded distribute_setup.py to.
Run distribute_setup: python distribute_setup.py (This will not work if your python installation directory is not added to your path - go here for help)
Change the current directory to the Scripts directory for your Python installation (C:\Python27\Scripts) or add that directory, as well as the Python base installation directory to your %PATH% environment variable.
Install pip using the newly installed setuptools: easy_install pip
The last step will not work unless you're either in the directory easy_install.exe is located in (C:\Python27\Scripts would be the default for Python 2.7), or you have that directory added to your path.
OLD Method 1 using ez_setup:
from the setuptools page --
Download ez_setup.py and run it; it will download the appropriate .egg file and install it for you. (Currently, the provided .exe installer does not support 64-bit versions of Python for Windows, due to a distutils installer compatibility issue.
After this, you may continue with:
Add c:\Python2x\Scripts to the Windows path (replace the x in Python2x with the actual version number you have installed)
Open a new (!) DOS prompt. From there run easy_install pip
2016+ Update:
These answers are outdated or otherwise wordy and difficult.
If you've got Python 3.4+ or 2.7.9+, it will be installed by default on Windows. Otherwise, in short:
Download the pip installer:
https://bootstrap.pypa.io/get-pip.py
If paranoid, inspect file to confirm it isn't malicious
(must b64 decode).
Open a console in the download folder as Admin and run
get-pip.py. Alternatively, right-click its icon in Explorer and choose the "run as Admin...".
The new binaries pip.exe (and the deprecated easy_install.exe) will be found in the "%ProgramFiles%\PythonXX\Scripts" folder (or similar), which is often not in your PATH variable. I recommend adding it.
Python 3.4, which was released in March 2014, comes with pip included:
http://docs.python.org/3.4/whatsnew/3.4.html
So, since the release of Python 3.4, the up-to-date way to install pip on Windows is to just install Python.
The recommended way to use it is to call it as a module, especially with multiple python distributions or versions installed, to guarantee packages go to the correct place:
python -m pip install --upgrade packageXYZ
https://docs.python.org/3/installing/#work-with-multiple-versions-of-python-installed-in-parallel
When I have to use Windows, I use ActivePython, which automatically adds everything to your PATH and includes a package manager called PyPM which provides binary package management making it faster and simpler to install packages.
pip and easy_install aren't exactly the same thing, so there are some things you can get through pip but not easy_install and vice versa.
My recommendation is that you get ActivePython Community Edition and don't worry about the huge hassle of getting everything set up for Python on Windows. Then, you can just use pypm.
In case you want to use pip you have to check the PyPM option in the ActiveState installer. After installation you only need to logoff and log on again, and pip will be available on the commandline, because it is contained in the ActiveState installer PyPM option and the paths have been set by the installer for you already. PyPM will also be available, but you do not have to use it.
The up-to-date way is to use Windows' package manager Chocolatey.
Once this is installed, all you have to do is open a command prompt and run the following the three commands below, which will install Python 2.7, easy_install and pip. It will automatically detect whether you're on x64 or x86 Windows.
cinst python
cinst easy.install
cinst pip
All of the other Python packages on the Chocolatey Gallery can be found here.
Update March 2015
Python 2.7.9 and later (on the Python 2 series), and Python 3.4 and later include pip by default, so you may have pip already.
If you don't, run this one line command on your prompt (which may require administrator access):
python -c "exec('try: from urllib2 import urlopen \nexcept: from urllib.request import urlopen');f=urlopen('https://bootstrap.pypa.io/get-pip.py').read();exec(f)"
It will install pip. If Setuptools is not already installed, get-pip.py will install it for you too.
As mentioned in comments, the above command will download code from the Pip source code repository at GitHub, and dynamically run it at your environment. So be noticed that this is a shortcut of the steps download, inspect and run, all with a single command using Python itself. If you trust Pip, proceed without doubt.
Be sure that your Windows environment variable PATH includes Python's folders (for Python 2.7.x default install: C:\Python27 and C:\Python27\Scripts, for Python 3.3x: C:\Python33 and C:\Python33\Scripts, and so on).
Installers
I've built Windows installers for both distribute and pip here (the goal being to use pip without having to either bootstrap with easy_install or save and run Python scripts):
distribute-0.6.27.win32.exe
pip-1.1.win32.exe
On Windows, simply download and install first distribute, then pip from the above links. The distribute link above does contain stub .exe installers, and these are currently 32-bit only. I haven't tested the effect on 64-bit Windows.
Building on Windows
The process to redo this for new versions is not difficult, and I've included it here for reference.
Building distribute
In order to get the stub .exe files, you need to have a Visual C++ compiler (it is apparently compilable with MinGW as well)
hg clone https://bitbucket.org/tarek/distribute
cd distribute
hg checkout 0.6.27
rem optionally, comment out tag_build and tag_svn_revision in setup.cfg
msvc-build-launcher.cmd
python setup.py bdist_win32
cd ..
echo build is in distribute\dist
Building pip
git clone https://github.com/pypa/pip.git
cd pip
git checkout 1.1
python setup.py bdist_win32
cd ..
echo build is in pip\dist
The following works for Python 2.7. Save this script and launch it:
https://raw.github.com/pypa/pip/master/contrib/get-pip.py
Pip is installed, then add the path to your environment :
C:\Python27\Scripts
Finally
pip install virtualenv
Also you need Microsoft Visual C++ 2008 Express to get the good compiler and avoid these kind of messages when installing packages:
error: Unable to find vcvarsall.bat
If you have a 64-bit version of Windows 7, you may read 64-bit Python installation issues on 64-bit Windows 7 to successfully install the Python executable package (issue with registry entries).
For the latest Python download - I have Python 3.6 on Windows. You don't have to wonder. Everything you need is there. Take a breath, and I will show you how to do it.
Make sure where you install Python. For me, it was in the following directory
Now, let’s add the Python and pip into environment variable path settings
if you are on Windows, so that typing pip or python anywhere call
python or pip from where they are installed.
So, PIP is found under the folder in the above screen "SCRIPTS"
Let's add Python and PIP in the environment variable path.
Almost done. Let's test with CMD to install the google package using pip.
pip install google
To install pip globally on Python 2.x, easy_install appears to be the best solution as Adrián states.
However the installation instructions for pip recommend using virtualenv since every virtualenv has pip installed in it automatically. This does not require root access or modify your system Python installation.
Installing virtualenv still requires easy_install though.
2018 update:
Python 3.3+ now includes the venv module for easily creating virtual environments like so:
python3 -m venv /path/to/new/virtual/environment
See documentation for different platform methods of activating the environment after creation, but typically one of:
$ source <venv>/bin/activate
C:\> <venv>\Scripts\activate.bat
To use pip, it is not mandatory that you need to install pip in the system directly. You can use it through virtualenv. What you can do is follow these steps:
Download virtualenv tar.gz file from https://pypi.python.org/pypi/virtualenv
Unzip it with 7zip or some other tool
We normally need to install Python packages for one particular project. So, now create a project folder, let’s say myproject.
Copy the virtualenv.py file from the decompressed folder of virtualenv, and paste inside the myproject folder
Now create a virtual environment, let’s say myvirtualenv as follows, inside the myproject folder:
python virtualenv.py myvirtualenv
It will show you:
New python executable in myvirtualenv\Scripts\python.exe
Installing setuptools....................................done.
Installing pip.........................done.
Now your virtual environment, myvirtualenv, is created inside your project folder. You might notice, pip is now installed inside you virtual environment. All you need to do is activate the virtual environment with the following command.
myvirtualenv\Scripts\activate
You will see the following at the command prompt:
(myvirtualenv) PATH\TO\YOUR\PROJECT\FOLDER>pip install package_name
Now you can start using pip, but make sure you have activated the virtualenv looking at the left of your prompt.
This is one of the easiest way to install pip i.e. inside virtual environment, but you need to have virtualenv.py file with you.
For more ways to install pip/virtualenv/virtualenvwrapper, you can refer to thegauraw.tumblr.com.
Updated at 2016 : Pip should already be included in Python 2.7.9+ or 3.4+, but if for whatever reason it is not there, you can use the following one-liner.
Download https://bootstrap.pypa.io/get-pip.py and run it with Administrator permission python get-pip.py (If you are on Linux, use sudo python get-pip.py)
PS:
This should already be satisfied in most cases but, if necessary, be sure that your environment variable PATH includes Python's folders (for example, Python 2.7.x on Windows default install: C:\Python27 and C:\Python27\Scripts, for Python 3.3x: C:\Python33 and C:\Python33\Scripts, etc)
I encounter same problem and then found such perhaps easiest way (one liner!) mentioned on official website here: http://www.pip-installer.org/en/latest/installing.html
Can't believe there are so many lengthy (perhaps outdated?) answers out there. Feeling thankful to them but, please up-vote this short answer to help more new comers!
I just wanted to add one more solution for those having issues installing setuptools from Windows 64-bit. The issue is discussed in this bug on python.org and is still unresolved as of the date of this comment. A simple workaround is mentioned and it works flawlessly. One registry change did the trick for me.
Link: http://bugs.python.org/issue6792#
Solution that worked for me...:
Add this registry setting for 2.6+ versions of Python:
[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Python\PythonCore\2.6\InstallPath]
#="C:\\Python26\\"
This is most likely the registry setting you will already have for Python 2.6+:
[HKEY_LOCAL_MACHINE\SOFTWARE\Python\PythonCore\2.6\InstallPath]
#="C:\\Python26\\"
Clearly, you will need to replace the 2.6 version with whatever version of Python you are running.
The best way I found so far, is just two lines of code:
curl http://python-distribute.org/distribute_setup.py | python
curl https://raw.github.com/pypa/pip/master/contrib/get-pip.py | python
It was tested on Windows 8 with PowerShell, Cmd, and Git Bash (MinGW).
And you probably want to add the path to your environment. It's somewhere like C:\Python33\Scripts.
PythonXY comes with pip included, among others.
I use the cross-platform Anaconda package manager from continuum.io on Windows and it is reliable. It has virtual environment management and a fully featured shell with common utilities (e.g. conda, pip).
> conda install <package> # access distributed binaries
> pip install <package> # access PyPI packages
conda also comes with binaries for libraries with non-Python dependencies, e.g. pandas, numpy, etc. This proves useful particularly on Windows as it can be hard to correctly compile C dependencies.
Here how to install pip the easy way.
Copy and paste this content in a file as get-pip.py.
Copy and paste get-pip.py into the Python folder.C:\Python27.
Double click on get-pip.py file. It will install pip on your computer.
Now you have to add C:\Python27\Scripts path to your environment variable. Because it includes the pip.exe file.
Now you are ready to use pip. Open cmd and type as pip install package_name
I had some issues installing in different ways when I followed instructions here. I think it's very tricky to install in every Windows environment in the same way. In my case I need Python 2.6, 2.7 and 3.3 in the same machine for different purposes so that's why I think there're more problems.
But the following instructions worked perfectly for me, so might be depending on your environment you should try this one:
http://docs.python-guide.org/en/latest/starting/install/win/
Also, due to the different environments I found incredible useful to use Virtual Environments, I had websites that use different libraries and it's much better to encapsulate them into a single folder, check out the instructions, briefly if PIP is installed you just install VirtualEnv:
pip install virtualenv
Into the folder you have all your files run
virtualenv venv
And seconds later you have a virtual environment with everything in venv folder, to activate it run venv/Scripts/activate.bat (deactivate the environment is easy, use deactivate.bat). Every library you install will end up in venv\Lib\site-packages and it's easy to move your whole environment somewhere.
The only downside I found is some code editors can't recognize this kind of environments, and you will see warnings in your code because imported libraries are not found. Of course there're tricky ways to do it but it would be nice editors keep in mind Virtual Environments are very normal nowadays.
Hope it helps.
Download script: https://raw.github.com/pypa/pip/master/contrib/get-pip.py
Save it on drive somewhere like C:\pip-script\get-pip.py
Navigate to that path from command prompt and run " python get-pip.py "
Guide link: http://www.pip-installer.org/en/latest/installing.html#install-pip
Note: Make sure scripts path like this (C:\Python27\Scripts) is added int %PATH% environment variable as well.
It's very simple:
Step 1: wget https://bitbucket.org/pypa/setuptools/raw/bootstrap/ez_setup.py
Step 2: wget https://raw.github.com/pypa/pip/master/contrib/get-pip.py
Step 2: python ez_setup.py
Step 3: python get-pip.py
(Make sure your Python and Python script directory (for example, C:\Python27 and C:\Python27\Scripts) are in the PATH.)
Working as of Feb 04 2014 :):
If you have tried installing pip through the Windows installer file from http://www.lfd.uci.edu/~gohlke/pythonlibs/#pip as suggested by #Colonel Panic, you might have installed the pip package manager successfully, but you might be unable to install any packages with pip. You might also have got the same SSL error as I got when I tried to install Beautiful Soup 4 if you look in the pip.log file:
Downloading/unpacking beautifulsoup4
Getting page https://pypi.python.org/simple/beautifulsoup4/
Could not fetch URL https://pypi.python.org/simple/beautifulsoup4/: **connection error: [Errno 1] _ssl.c:504: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed**
Will skip URL https://pypi.python.org/simple/beautifulsoup4/ when looking for download links for beautifulsoup4
The problem is an issue with an old version of OpenSSL being incompatible with pip 1.3.1 and above versions. The easy workaround for now, is to install pip 1.2.1, which does not require SSL:
Installing Pip on Windows:
Download pip 1.2.1 from https://pypi.python.org/packages/source/p/pip/pip-1.2.1.tar.gz
Extract the pip-1.2.1.tar.gz file
Change directory to the extracted folder: cd <path to extracted folder>/pip-1.2.1
Run python setup.py install
Now make sure C:\Python27\Scripts is in PATH because pip is installed in the C:\Python27\Scripts directory unlike C:\Python27\Lib\site-packages where Python packages are normally installed
Now try to install any package using pip.
For example, to install the requests package using pip, run this from cmd:
pip install requests
Whola! requests will be successfully installed and you will get a success message.
Simple CMD way
Use CURL to download get-pip.py:
curl --http1.1 https://bootstrap.pypa.io/get-pip.py --output get-pip.py
Execute the downloaded Python file
python get-pip.py
Then add C:\Python37\Scripts path to your environment variable. It assumes that there is a Python37 folder in your C drive. That folder name may vary according to the installed Python version
Now you can install Python packages by running
pip install awesome_package_name
Installing Pip for Python 2 and Python 3
Download get-pip.py to a folder on your computer.
Open a command prompt and navigate to the folder containing get-pip.py.
Run the following command:python get-pip.py, python3 get-pip.py or python3.6 get-pip.py, depending on which version of Python you want to install pip
Pip should be now installed!
Old answer (still valid)
Try:
python -m ensurepip
It's probably the easiest way to install pip on any system.
If you even have other problems with the pip version, you can try this:
pip install --trusted-host pypi.python.org --upgrade pip
pip is already installed if you're using Python 2 >= 2.7.9 or Python 3 >= 3.4 binaries downloaded from python.org, but you'll need to upgrade pip.
On Windows, the upgrade can be done easily:
Go to a Python command line and run the below Python command
python -m pip install -U pip
Installing with get-pip.py
Download get-pip.py in the same folder or any other folder of your choice. I am assuming you will download it in the same folder from where you have the python.exe file and run this command:
python get-pip.py
Pip's installation guide is pretty clean and simple.
Using this, you should be able to get started with Pip in under two minutes.
Now, it is bundled with Python. You don't need to install it.
pip -V
This is how you can check whether pip is installed or not.
In rare cases, if it is not installed, download the get-pip.py file and run it with Python as
python get-pip.py
I think the question makes it seem like the answer is simpler than it really is.
Running of pip will sometimes require native compilation of a module (64-bit NumPy is a common example of that). In order for pip's compilation to succeed, you need Python which was compiled with the same version of Microsoft Visual C++ as the one pip is using.
Standard Python distributions are compiled with Microsoft Visual C++ 2008. You can install an Express version of Microsoft Visual C++ 2008, but it is not maintained. Your best bet is to get an express version of a later Microsoft Visual C++ and compile Python. Then PIP and Python will be using the same Microsoft Visual C++ version.
Just download setuptools-15.2.zip (md5), from here https://pypi.python.org/pypi/setuptools#windows-simplified , and run ez_setup.py.

Resources