Anaconda site-packages

166,140

Solution 1

You can import the module and check the module.__file__ string. It contains the path to the associated source file.

Alternatively, you can read the File tag in the the module documentation, which can be accessed using help(module), or module? in IPython.

Solution 2

Run this inside python shell:

from distutils.sysconfig import get_python_lib
print(get_python_lib())

Solution 3

Linux users can find the locations of all the installed packages like this:

pip list | xargs -exec pip show

Updated 2022-03-21 to remove the unwanted table heading at the top of pip list output:

pip list | tail -n +3 | xargs -exec pip show

Solution 4

One more option using the interpreter:

import site; print(''.join(site.getsitepackages()))

And using a terminal/prompt:

python -c "import site; print(''.join(site.getsitepackages()))"

Also in this case you can easily print one of the directory (in case there are more than one) using own filter

Solution 5

I installed miniconda and found all the installed packages in /miniconda3/pkgs

Share:
166,140
Nyxynyx
Author by

Nyxynyx

Hello :) I have no formal education in programming :( And I need your help! :D These days its web development: Node.js Meteor.js Python PHP Laravel Javascript / jQuery d3.js MySQL PostgreSQL MongoDB PostGIS

Updated on July 25, 2022

Comments

  • Nyxynyx
    Nyxynyx almost 2 years

    After installing a package in an anaconda environment, I'll like to make some changes to the code in that package.

    Where can I find the site-packages directory containing the installed packages? I do not find a directory /Users/username/anaconda/lib/python2.7/site-packages

  • Codious-JR
    Codious-JR about 8 years
    conda list, just gave me " packages in environment at /Users/user/anaconda:" as output. The exact location for the packages was required, which is /Users/user/anaconda/lib/python2.7/'.
  • ivan-k
    ivan-k about 8 years
    Here is some elegant use of xargs!
  • Ben Farmer
    Ben Farmer over 4 years
    My problem is that I get a package import "not found" error for the package that conda supposedly installed. So I would like to check where conda thinks that it installed the package.
  • Arcturus B
    Arcturus B over 4 years
    @BenFarmer: this sounds like a rather different problem. Have you tried searching for something along the line of "conda list installed package paths"? This returns stackoverflow.com/q/46767012 and stackoverflow.com/q/47138241.
  • Christian4145
    Christian4145 about 4 years
    'conda list' is a very good idea when you want to know from which repository a package was installed. It also shows an installation via pip. So this is a really good tip although it does not answer the question.
  • BrB
    BrB about 4 years
    thanks @Arcturus B just adding one example example: >>import tensorflow >>tensorflow.__file__
  • Dan Nissenbaum
    Dan Nissenbaum about 4 years
    This answer actually works for me - not sure why it's downvoted! conda list, as its first line, spits out the root of your conda installation; inside that is the pkgs folder.
  • Dan Nissenbaum
    Dan Nissenbaum about 4 years
    ... actually (re. my preceding comment), inside the root of the miniconda installation I find some packages at 'lib/python3.7/site-packages'
  • numbers3567
    numbers3567 almost 4 years
    i just used: pip show <package-name>. It worked, I got the files.
  • Charlie Parker
    Charlie Parker over 3 years
    but he said he is using conda...?
  • Charlie Parker
    Charlie Parker over 3 years
    my problem is that I see it in conda list but I can't find where it would be located...any ideas?
  • Charlie Parker
    Charlie Parker over 3 years
    my problem is that I see it in conda list but I can't find where it would be located...any ideas?
  • Charlie Parker
    Charlie Parker over 3 years
    my problem is that I see it in conda list but I can't find where it would be located...any ideas?
  • Charlie Parker
    Charlie Parker over 3 years
    my problem is that I see it in conda list but I can't find where it would be located...any ideas?
  • Martijn Pieters
    Martijn Pieters over 3 years
    @CharlieParker it sounds like you want to be able to list the files in a given conda package: stackoverflow.com/questions/47138241/…. Verify that the package is installed in the correct environment (the one your Python binary is part of), and that it includes files in directories that Python looks at (list those paths with python -m site).
  • merv
    merv almost 2 years
    The Conda package cache is not the same as the Python's site-packages. You shouldn't mess with these, otherwise you'll could end up with corruption complaints from Conda.
  • merv
    merv almost 2 years
    That is the package cache, which is not the same as site-packages for the Python installation.