30

The default location where pip installes packages on my Ubuntu system is '/usr/local/lib/pytho2.7/dist-packages/' which I think is the default in general. I am using Enthought python distribution (EPD not canopy) and would like to install a package into EPD as I usually work with the python from the EPD distribution on my system. I would like to know into which directory inside EPD the new files need to be installed using pip ; as the directory structure for EPD on linux seems to be quite different from the EPD directory structure on MAC OS for where there seem to be many examples.

Also I have come across this :

pip install --install-option="--prefix=$PREFIX_PATH" package_name

as the accepted answer to a question similar to this. I would like to know what the purpose of the $PREFIX_PATH environment variable is as mine is currently blank. And what path I need to specify on Ubuntu for my Enthought EPD distribution to install python modules.

I apologize for the relatively naive question but I am quite new to EPD on ubuntu and am still trying to figure it out.

user2502020
  • 371
  • 1
  • 3
  • 6

6 Answers6

51

This line should work for everyone, as mentioned in the documentation.

pip install package_name -t any/path/i/like

PS:

And to address the comment of @CPiLL, the any/path/i/like can really be anything, such as /tmp/my-test-env. The package being installed in this way will NOT be available for your usual python environment, in fact they will NOT even show up using pip list. And python -c "import package_name" will generally FAIL with ImportError exception, unless you cd into that folder first:

cd /tmp/my-test-env
python -c "import package-name"

How this technique would be useful is beyond this answer.

RayLuo
  • 17,257
  • 6
  • 88
  • 73
5

System: Ubuntu 12.04, Enthought Python Distribution (this is where I wanted to install a new python module)

So the prefix_path environment variable didn't work for me and pip still kept installing it in the default location. But I used How do I change the default directory that pip installs to?

question as a guide. And one of the answers helped me achieve what I needed.

 pip install -d <path_to_my_directory>  

For the path I used: path_to_epd_directory/lib/python2.7/site-packages

This puts the tar.gz file into the site-packages

Then extract it using:

tar -zxvf pymodule.tar.gz

a directory named pymodule is created, cd into that module and type:

 python setup.py install

and that should do the job.

Community
  • 1
  • 1
user2502020
  • 371
  • 1
  • 3
  • 6
-1

Instead, you could use a copy of pip that has been installed into your EPD installation.

$ path-to-EPD/bin/enpkg pip # Or simply enpkg pip, if EPD is on your PATH. 
$ path-to-EPD/bin/pip install <package-name>
punchagan
  • 5,566
  • 1
  • 19
  • 23
-1

This worked for me on Ubuntu Gnome 17.04. Installing PyMySQL to specific dir:

sudo pip install PyMySQL -t /home/mahmoud/app
sheldonzy
  • 5,505
  • 9
  • 48
  • 86
mahmoud alaa
  • 101
  • 1
  • 7
-1

This answer worked in windows OS
Short answer: To install package to the specific folder using -t option ex:pip install packageX -t lib/, then add this folder to PYTHONPAHT

Long answer:

  1. install virtualenv to .env folder

  2. pip install with -t option, example install to lib folder of my project (named 3)
    (.env) d:\tmp\3>pip install packageX -t lib/

  3. show list of packages :

    (.env) d:\tmp\3>pip list
    Package    Version
    ---------- ----------
    pip        18.1
    setuptools 40.6.3
    ...
  1. Not see your package ? open command-prompt as administrator right and set PYTHONPATH

enter image description here

  1. now new command prompt and activate env will see your packages enter image description here
nguyên
  • 5,156
  • 5
  • 43
  • 45
-1

You can use this code to install you package to a specific path.

pip install [package name] --target /path/to
zxw
  • 27
  • 4
  • 4
    Please consider adding a comment to what your code does. A single code line without any feedback is a very low quality answer – Simas Joneliunas Jan 07 '20 at 01:44
  • 2
    This is the same as the top answer from years ago. `-t` is just shorthand for `--target`. – wim Jan 07 '20 at 05:36