Installing Python library from WHL file [duplicate] - python

This question already has answers here:
How do I install a Python package with a .whl file?
(18 answers)
Closed 5 years ago.
Skill level: beginner
I am trying to add a library in python. The extension is wheel.
Can somebody tell stepwise approach in installing wheel file?

First open a console then cd to where you've downloaded your file like some-package.whl and use
pip install some-package.whl
Note: if pip.exe is not recognized, you may find it in the "Scripts" directory from where python has been installed. I have multiple Python installations, and needed to use the pip associated with Python 3 to install a version 3 wheel.
If pip is not installed, and you are using Windows: How to install pip on Windows?

From How do I install a Python package with a .whl file?
[sic],
How do I install a Python package USING a .whl file ?
For all Windows platforms:
1) Download the .WHL package install file.
2) Make Sure path [C:\Progra~1\Python27\Scripts] is in the system PATH string. This is for using both [pip.exe] and [easy-install.exe].
3) Make sure the latest version of pip.EXE is now installed.
At this time of posting:
pip.EXE --version
pip 9.0.1 from C:\PROGRA~1\Python27\lib\site-packages (python 2.7)
4) Run pip.EXE in an Admin command shell.
- Open an Admin privileged command shell.
> easy_install.EXE --upgrade pip
- Check the pip.EXE version:
> pip.EXE --version
pip 9.0.1 from C:\PROGRA~1\Python27\lib\site-packages (python 2.7)
> pip.EXE install --use-wheel --no-index
--find-links="X:\path to wheel file\DownloadedWheelFile.whl"
Be sure to double-quote paths or path\filenames with embedded spaces in them ! Alternatively, use the MSW 'short' paths and filenames.

Related

How to install a package for a specific Python version on Windows 10?

I currently have Python 3.7.4(64 bit) and Python 3.6.6(64 bit) on a Windows 10 64 bit laptop with both versions in my system environment variables(path).
I previously only had 3.7 and installed 3.6 to use pocketsphinx, and now I want to upgrade PyAudio of my 3.6. doing pip install --upgrade pyaudio is upgrading the pyaudio of 3.7. So, how do i upgrade(or even install) packages of specific python versions on a windows machine?
Here's also what I've tried:
python-3.6.6 pip install --upgrade pyaudio,
python3.6.6 pip install --upgrade pyaudio,
python3.6 pip install --upgrade pyaudio and
pip3.6.6 install --upgrade pyaudio.
Yes, these may be stupid, but I was helpless.
EDIT 1:
I also run pip install --upgrade pyaudio in power shell by opening it in the directory where my python 3.6 is installed, which is(default installation directory for windows): C:\Users\--user-name--\AppData\Local\Programs\Python\Python36 like:
as you can see from the version, pip install would still install new packages for python 3.7
In CMD or powershell ,
for installing in Python 3.7:-
>py -3.7 -m pip install --upgrade pyaudio
for installing in Python 3.6:-
>py -3.6 -m pip install --upgrade pyaudio
Hope it helps ๐Ÿ‘๐Ÿ˜Š
The golden rule when one wants to access one of the multiple software versions (applies to any software (other than Python), on any OS) existing on a machine: use absolute paths.
There are multiple ways of pip installing (especially when involving VEnvs):
Run PIP directly - most frequently used:
pip install --upgrade pyaudio
Run python -m pip:
python -m pip install --upgrade pyaudio
Run other convenience wrappers (Py (Win specific): [Python.Docs]: Using Python on Windows - From the command-line):
py -3.6 -m pip install --upgrade pyaudio
But the form that I prefer (as it will always work - because it doesn't rely on environment variables like PATH), is the 2nd one:
"${PATH_TO_YOUR_PYTHON_3_6}" -m pip install --upgrade pyaudio
where ${PATH_TO_YOUR_PYTHON_3_6} is just a placeholder for the actual Python 3.6 executable path (e.g. %ProgramFiles%\Python 3.6\python.exe).
Note that this works fine (end easy) when having multiple Python versions installed (custom built, VEnvs, ...).
Check [Python.Docs]: Using Python on Windows - Installing Without UI for more details regarding install paths.
Generalizing:
"${PATH_TO_PYTHON_EXECUTABLE}" -m pip install ${PACKAGE_NAME}
where ${PACKAGE_NAME} is (obviously) the package name.
Note that sometimes, due to special conditions (like local PIP repositories configuration, ...), the installation would have to be done in 2 steps:
Download the .whl locally
Pass it to PIP (in order to install it)
as described in [SO]: Installing pygraphviz on Windows 10 64-bit, Python 3.6 (#CristiFati's answer) (Shortcut section (somewhere at the end)).
${PATH_TO_PYTHON_EXECUTABLE} (using v3.9 as an example) can be (from my machines):
Win:
%ProgramFiles%\Python 3.9\python.exe
E:\Work\Dev\VEnvs\py_pc064_03.09_test0\Scripts\python.exe
F:\Install\pc064\Anaconda\Anaconda\Version\python.exe
Nix:
/usr/bin/python3.9
/opt/qti-aic/dev/python/qaic-env/bin/python
When not sure about an executable location (actually not limited to executables), that can be checked:
Win: [MS.Docs]: where (where /?)
Nix: [Die.Linux]: which(1) (man which).
Worth mentioning aliases: [Man7]: ALIAS(1P) (man alias)
Might also worth reading:
[SO]: PyCharm doesn't recognize installed module (#CristiFati's answer)
[SO]: How to update pywin32 automatically? (#CristiFati's answer)
[SO]: PyAudio.write SystemError: PY_SSIZE_T_CLEAN macro must be defined for '#' formats (#CristiFati's answer)
Please use the -m flag, when binding to the specific python,
$ py3.6 -m pip install --upgrade pyaudio
From the docs and is the recommended way to install modules,
The Python installers for Windows include pip. You should be able to
access pip using:
py -m pip --version pip 9.0.1 from c:\python36\lib\site-packages
(Python 3.6.1)
You can make sure that pip is up-to-date by running:
py -m pip install --upgrade pip
But i recommend you use some virtualenv for this.

No module named 'pip._internal'; 'pip' is not a package [duplicate]

This question already has answers here:
pip: no module named _internal
(30 answers)
Closed last month.
I am new to using python, and am wanting to be able to install packages for python using pip. I am having trouble running pip on my windows computer. When typing in "pip --version" into command prompt I get:
ModuleNotFoundError: No module named 'pip._internal'; 'pip' is not a package
I have added the scripts folder to the PATH environment variable as shown on the picture in this link
Environment variables photo
(Stack overflow does not allow embedded pictures if you are new)
This is the contents of my scripts directory where pip is present:
Directory of C:\Users\....\AppData\Local\Programs\Python\Python37-32\Scripts
[.] [..] easy_install-3.7.exe
easy_install.exe pip-script.py pip.exe
pip.exe.manifest pip3 pip3-script.py
pip3.7-script.py pip3.7.exe pip3.7.exe.manifest
pip3.exe pip3.exe.manifest wheel.exe
Any help on this would be appreciated
Force a reinstall of pip:
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
python3 get-pip.py --force-reinstall
For windows you may have to choco install curl or set PATH to where python3 is located
In cmd try using
py -3.6 -m pip install pygmae
replace 3.6 with your version of python and add -32 fot 32 bit version
py -3.6-32 pip install pygame
replace pygame with the module you want to install
this works for most people using python on windows also reboot your pc after adding system variable path

Where to place wheel file for installation using pip?

Where to place wheel file for installation using pip?
I want to install NumPy on Windows 7 on Python 3.6.2, using Christoph Gohlke's wheel:
numpy-1.14.3+mkl-cp36-cp36m-win_amd64.whl.
The link at How do I install a Python package with a .whl file? says I can install it using pip with the following command:
pip install C:/some-dir/some-file.whl
My question is: where should I place the wheel file prior to installing it? Should it be placed in the Python folder C:\Program Files\Python36\ or can I place the wheel file at any arbitrary location and still have it install correctly? I assume the actual installation will be in the Python36 folder to enable importing into Python, but I don't want to mess up the installation by putting the wheel file in the wrong place.
Thanks for any help on this.
The answer to this question is you can place it anywhere on your computer. On Windows, install it from the Python command prompt with:
py -m pip install full_path_to_Package

Trying to install pygame for python 3.6, running into difficulties [duplicate]

I'm having trouble installing a Python package on my Windows machine, and would like to install it with Christoph Gohlke's Window binaries. (Which, to my experience, alleviated much of the fuss for many other package installations). However, only .whl files are available.
http://www.lfd.uci.edu/~gohlke/pythonlibs/#jpype
But how do I install .whl files?
Notes
I've found documents on wheel, but they don't seem so staightforward in explaining how to install .whl files.
This question is a duplicate with this question, which wasn't directly answered.
I just used the following which was quite simple. First open a console then cd to where you've downloaded your file like some-package.whl and use
pip install some-package.whl
Note: if pip.exe is not recognized, you may find it in the "Scripts" directory from where python has been installed. If pip is not installed, this page can help:
How do I install pip on Windows?
Note: for clarification
If you copy the *.whl file to your local drive (ex. C:\some-dir\some-file.whl) use the following command line parameters --
pip install C:/some-dir/some-file.whl
First, make sure you have updated pip to enable wheel support:
pip install --upgrade pip
Then, to install from wheel, give it the directory where the wheel is downloaded. For example, to install package_name.whl:
pip install --use-wheel --no-index --find-links=/where/its/downloaded package_name
There are several file versions on the great Christoph Gohlke's site.
Something I have found important when installing wheels from this site is to first run this from the Python console:
import pip
print(pip.pep425tags.get_supported())
so that you know which version you should install for your computer. Picking the wrong version may fail the installing of the package (especially if you don't use the right CPython tag, for example, cp27).
I am in the same boat as the OP.
Using a Windows command prompt, from directory:
C:\Python34\Scripts>
pip install wheel
seemed to work.
Changing directory to where the whl was located, it just tells me 'pip is not recognized'. Going back to C:\Python34\Scripts>, then using the full command above to provide the 'where/its/downloaded' location, it says Requirement 'scikit_image-...-win32.whl' looks like a filename, but the filename does not exist.
So I dropped a copy of the .whl in Python34/Scripts, ran the exact same command over again (with the --find-links= still going to the other folder), and this time it worked.
There's a slight difference between accessing the .whl file in python2 and python3. In python3, you need to install wheel first and then you can access .whl files.
Python3
pip install package.whl
OR
pip install wheel
And then by using wheel
wheel unpack some-package.whl
Python2
pip install some-package.whl
You have to run pip.exe from the command prompt on my computer.
I type C:/Python27/Scripts/pip2.exe install numpy
On Windows you can't just upgrade using pip install --upgrade pip, because the pip.exe is in use and there would be an error replacing it. Instead, you should upgrade pip like this:
easy_install --upgrade pip
Then check the pip version:
pip --version
If it shows 6.x series, there is wheel support.
Only then, you can install a wheel package like this:
pip install your-package.whl
To be able to install wheel files with a simple doubleclick on them you can do one the following:
1) Run two commands in command line under administrator privileges:
assoc .whl=pythonwheel
ftype pythonwheel=cmd /c pip.exe install "%1" ^& pause
2) Alternatively, they can be copied into a wheel.bat file and executed with 'Run as administrator' checkbox in the properties.
PS pip.exe is assumed to be in the PATH.
Update:
(1) Those can be combined in one line:
assoc .whl=pythonwheel& ftype pythonwheel=cmd /c pip.exe install -U "%1" ^& pause
(2) Syntax for .bat files is slightly different:
assoc .whl=pythonwheel& ftype pythonwheel=cmd /c pip.exe install -U "%%1" ^& pause
Also its output can be made more verbose:
#assoc .whl=pythonwheel|| echo Run me with administrator rights! && pause && exit 1
#ftype pythonwheel=cmd /c pip.exe install -U "%%1" ^& pause || echo Installation error && pause && exit 1
#echo Installation successfull & pause
see my blog post for details.
In-case if you unable to install specific package directly using PIP.
You can download a specific .whl (wheel) package from - https://www.lfd.uci.edu/~gohlke/pythonlibs/
CD (Change directory) to that downloaded package and install it manually by -
pip install PACKAGENAME.whl
ex:
pip install ad3โ€‘2.1โ€‘cp27โ€‘cp27mโ€‘win32.whl
EDIT: THIS NO LONGER IS A PART OF PIP
To avoid having to download such files, you can try:
pip install --use-wheel pillow
For more information, see this.
You can install the .whl file, using pip install filename. Though to use it in this form, it should be in the same directory as your command line, otherwise specify the complete filename, along with its address like pip install C:\Some\PAth\filename.
Also make sure the .whl file is of the same platform as you are using, do a python -V to find out which version of Python you are running and if it is win32 or 64, install the correct version according to it.
The only way I managed to install NumPy was as follows:
I downloaded NumPy from here
https://pypi.python.org/pypi/numpy
This Module
https://pypi.python.org/packages/d7/3c/d8b473b517062cc700575889d79e7444c9b54c6072a22189d1831d2fbbce/numpy-1.11.2-cp35-none-win32.whl#md5=e485e06907826af5e1fc88608d0629a2
Command execution from Python's installation path in PowerShell
PS C:\Program Files (x86)\Python35-32> .\python -m pip install C:/Users/MyUsername/Documents/Programs/Python/numpy-1.11.2-cp35-none-win32.whl
Processing c:\users\MyUsername\documents\programs\numpy-1.11.2-cp35-none-win32.whl
Installing collected packages: numpy
Successfully installed numpy-1.11.2
PS C:\Program Files (x86)\Python35-32>
PS.: I installed it on Windows 10.
New Python users on Windows often forget to add Python's \Scripts directory to the PATH variable during the installation. I recommend to use the Python launcher and execute pip as a script with the -m switch. Then you can install the wheels for a specific Python version (if more than one are installed) and the Scripts directory doesn't have to be in the PATH. So open the command line, navigate (with the cd command) to the folder where the .whl file is located and enter:
py -3.6 -m pip install your_whl_file.whl
Replace 3.6 by your Python version or just enter -3 if the desired Python version appears first in the PATH. And with an active virtual environment: py -m pip install your_whl_file.whl.
Of course you can also install packages from PyPI in this way, e.g.
py -3.6 -m pip install pygame
I would be suggesting you the exact way how to install .whl file.
Initially I faced many issues but then I solved it, Here is my trick to install .whl files.
Follow The Steps properly in order to get a module imported
Make sure your .whl file is kept in the python 2.7/3.6/3.7/.. folder.
Initially when you download the .whl file the file is kept in downloaded folder, my
suggestion is to change the folder. It makes it easier to install the file.
Open command prompt and open the folder where you have kept the file by entering
cd c:\python 3.7
3.Now, enter the command written below
>py -3.7(version name) -m pip install (file name).whl
Click enter and make sure you enter the version you are currently using with correct
file name.
Once you press enter, wait for few minutes and the file will be installed and you will
be able to import the particular module.
In order to check if the module is installed successfully, import the module in idle
and check it.
Thank you:)
On the MacOS, with pip installed via MacPorts into the MacPorts python2.7, I had to use #Dunes solution:
sudo python -m pip install some-package.whl
Where python was replaced by the MacPorts python in my case, which is python2.7 or python3.5 for me.
The -m option is "Run library module as script" according to the manpage.
(I had previously run sudo port install py27-pip py27-wheel to install pip and wheel into my python 2.7 installation first.)
What I did was first updating the pip by using the command:
pip install --upgrade pip and then I also installed wheel by using command: pip install wheel and then it worked perfectly Fine.
Hope it works for you I guess.
Download the package (.whl).
Put the file inside the script folder of python directory
C:\Python36\Scripts
Use the command prompt to install the package.
C:\Python36\Scripts>pip install package_name.whl
Theoretically:
Because wheel is a built distribution spec ie, no dependency on a build system and because it's a ZIP-format archive, it just has to be unpacked to the target location in-order to be used.
While pip install *.wheel adds extra features, we can also unzip (using a standard archive tool eg: 7zip) the .whl file into site-packages directory to use the package.
https://packaging.python.org/specifications/binary-distribution-format/

Installing pep8 on Windows

Trying to install pep8 on Windows 7 machine. So I can use SublimeLiter for Sublime Text to lint through python scripts.
Did clear install of Python34. Checked in pip and system path options.
Tried:
Ran python pip install pep8. Output: python: can't open file 'pip': [Errno 2] No such file or directory
Downloaded get-pip.py from https://pip.pypa.io/en/latest/installing.html and ran C:/Python34/get-pip.py install pep8. Output:
Collecting install
Could not find any downloads that satisfy the requirement install
Some externally hosted files were ignored as access to them may be unreliable
(use --allow-external install to allow).
No distributions at all found for install
C:/Python34/get-pip.py install pep8. Output: command not found.
Any suggestions how can one install PEP8 on windows?
As Neitsa suggested, one should use -m (module) option for Windows in order to install modules via PiP.
Here is the working solution in CMD:
python -m pip install pep8
Credits goes to Naitsa.

Categories

Resources