Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Installing a .whl Python package into a specific directory other than the default

Tags:

python

I am trying to install the 64-bit version of NTLK, which comes in a .whl file, in a different directory than the standard python34/Lib folder. I am using Windows 10 64-bit and Python 3.4 64-bit.

I first tried using the instructions in this question (which worked for other modules).

The command I typed into CMD was:

py -m pip install --install-option="--prefix=$PATH_NAME" nltk-3.0.4-py2.py3-none-any.whl

It promptly gave me the following error:

UserWarning: Disabling all use of wheels due to the use of --build-options / --global-options / --install-options.

It appears that I can't install WHL files using the --install-option. Is there an alternate way I can install the .whl package in a non default directory?

Edit: I marked this as solved because the proposed solution allows me to do what I need in my own use case. However, it doesn't completely answer the question due to inherent limitations in using --root to choose an alternate directory. There is technically no correct solution to this problem, see the answer's comments for details.

Edit - March 3, 2017: It looks like this issue has been resolved in version 8.0 of PIP with the addition of the --prefix parameter. I've changed the accepted answer accordingly.

like image 381
Marlon Dyck Avatar asked Aug 13 '15 03:08

Marlon Dyck


1 Answers

You can use the --prefix option of pip install, available since version 8:

--prefix

Installation prefix where lib, bin and other top-level folders are placed

Note that pip uninstall does not have the --prefix option, so there is no obvious way to uninstall packages installed this way. As a workaround, set PYTHONUSERBASE to the prefix directory, e.g.:

PYTHONUSERBASE=prefix-dir python3 -m pip uninstall package-name
like image 194
Mihai Capotă Avatar answered Sep 18 '22 17:09

Mihai Capotă