Reputation: 63687
After installing a package in an Conda environment, I'd like to make some changes to the code in that package.
Where can I find the site-packages
directory containing the installed packages?
I have an Anaconda Python 2.7 base distribution, but I do not find a directory:
/Users/username/anaconda/lib/python2.7/site-packages
Upvotes: 137
Views: 332172
Reputation: 3768
This answer is for a generic Anaconda installation on Windows 11. If you are actually looking for a site-packages folder, there is one in c:\ProgramData\anaconda3\lib. One comment said the search was for installed modules (e.g. conda install foo), for them you might want to look in c:\ProgramData\ananconda3\pkgs.
You should also note: If you are in a virtual environment, there is also a site-packages folder in the .conda\lib folder at the root of that environment.
Upvotes: 2
Reputation: 76950
Generic approach for environment foo from Conda CLI would be:
conda run -n foo python -m site
which for my base environment looks like:
$ conda run -n base python -m site
sys.path = [
'/Users/mfansler/miniconda3/lib/python3.8',
'/Users/mfansler/miniconda3/lib/python38.zip',
'/Users/mfansler/miniconda3/lib/python3.8/lib-dynload',
'/Users/mfansler/miniconda3/lib/python3.8/site-packages',
]
USER_BASE: '/Users/mfansler/.local' (exists)
USER_SITE: '/Users/mfansler/.local/lib/python3.8/site-packages' (doesn't exist)
ENABLE_USER_SITE: True
The answer is the site-packages
in the sys.path
list.
Upvotes: 5
Reputation: 1292
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
Upvotes: 14
Reputation: 1240
The location should be (in Linux systems):
home/<USERNAME>/anaconda3/envs/<ENV_NAME>/lib/python<VERSION>/site-packages/
Upvotes: 17
Reputation: 1052
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
Upvotes: 11
Reputation: 17
At least with Miniconda (I assume it's the same for Anaconda), within the environment folder, the packages are installed in a folder called \conda-meta.
i.e.
C:\Users\username\Miniconda3\envs\environmentname\conda-meta
If you install on the base environment, the location is:
C:\Users\username\Miniconda3\pkgs
Upvotes: 1
Reputation: 617
I encountered this issue in my conda environment. The reason is that packages have been installed into two different folders, only one of which is recognised by the Python executable.
~/anaconda2/envs/[my_env]/site-packages ~/anaconda2/envs/[my_env]/lib/python2.7/site-packages
A proved solution is to add both folders to python path, using the following steps in command line (Please replace [my_env] with your own environment):
To ensure this works, try to activate Python in this environment, and import the package that was not found.
Upvotes: 1
Reputation: 371
You should find installed packages in :
anaconda's directory / lib / site_packages
That's where i found mine.
Upvotes: 3
Reputation: 59
I installed miniconda and found all the installed packages in /miniconda3/pkgs
Upvotes: 5
Reputation: 1105
Run this inside python shell:
from distutils.sysconfig import get_python_lib
print(get_python_lib())
Upvotes: 91
Reputation: 5631
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.
Upvotes: 160
Reputation: 163
You could also type 'conda list' in a command line. This will print out the installed modules with the version numbers. The path within your file structure will be printed at the top of this list.
Upvotes: 5