My passion for all things tech drives my hunt for all the coolz. I often need a vacation after I get back from vacation Join our mailing list to receive news, tips, strategies, and inspiration you need to grow your business.
Our Sales and Support teams are available 24 hours by phone or e-mail to assist. Search Search. Method 1. Method 2. Step 1. Step 2. Step 3. Step 4. Step 5. Step 6. Step 7. The installation of Python software falls under our Beyond Scope Support. This means it is not covered under our managed support, but we will do what we reasonably can to assist. Common Fixes Featured Articles Getting Started Other Products Learn more. How do I find the location of my Python site-packages directory?
Ask Question. Asked 13 years, 3 months ago. Active 8 days ago. Viewed 1. How do I find the location of my site-packages directory?
Improve this question. Daryl Spitzer Daryl Spitzer k 75 75 gold badges silver badges bronze badges. Add a comment. Active Oldest Votes. There are two types of site-packages directories, global and per user. In Python 3, you may use the sysconfig module instead: python3 -c 'import sysconfig; print sysconfig. Improve this answer. Peterino Peterino And to get the first one: python -c "import site; print site.
This should be in any basic tutorial on using python. I've been pythoning for years and didn't know about the site module. Would've saved so many headaches I have suggested a change to Python's official tutorial.
Please see PR for details, and thanks for the suggestion salotz! I think stackoverflow. Show 1 more comment. MERose 3, 7 7 gold badges 43 43 silver badges 73 73 bronze badges. This is good but, unfortunately, this function is available only from python2. So, nice solution if you are using python2. I get AttributeError: 'module' object has no attribute 'getsitepackages' when using with virtualenv python 2.
Show 5 more comments. A solution that: outside of virtualenv - provides the path of global site-packages, insidue a virtualenv - provides the virtualenv's site-packages Greg Dubicki 4, 2 2 gold badges 46 46 silver badges 59 59 bronze badges. Does virtualenv provide a way to find its site-packages? You can use virtualenvwrapper, which has the command cdsitepackages , to directly change into the environment's site-packages directory.
PiotrDobrogost: works for me on Python 2. First comment does not apply anymore: this showed the correct location both outside and inside a virtualenv. Show 2 more comments. For Ubuntu , python -c "from distutils. David Hollander David Hollander 1, 1 1 gold badge 7 7 silver badges 3 3 bronze badges.
If the asker is after a particular package's location, module. If they're trying to install things… just use the tools. Consider what problem virtualenv was created to solve — jfs. This is what worked for me: python -m site --user-site. Ramashri Ramashri 6 6 silver badges 2 2 bronze badges. This tells you where Python will look for user specific packages. Comments like "doesn't even exist" and "isn't what I wanted it to find" don't make sense in this context.
Python currently uses eight paths docs : stdlib : directory containing the standard Python library files that are not platform-specific. This is a great answer, I am happy the new sysconfig module makes this easier. Is there a way to get the local prefix platlib , as e.
Easily the best answer to this question! Thank you. The only thing that I found missing was the ordering in which these locations are checked when an import statement is encountered. Knowing that would also be useful IMO. In a venv created with --system-site-packages this doesn't list all searched directories - specifically the system site directories that are still searched are not listed here Agree with other comments.
This is a fantastic answer to the question and works in all contexts I've tried it in. If you have the py command installed, which you likely do, then just use the --list-paths argument to the command: py --list-paths Example output: Installed Pythons found by py Launcher for Windows In the sys package, you can find a lot of useful information about your installation: import sys print sys.
You could also try this for inspecting your sys module: import sys for k,v in sys. GuoH can we do the same using batch file? You could do something like python -c "import sys; print sys. Community Bot 1 1 1 silver badge. The problem I had with this solution is that I was running python 2.
I installed 3. To know where Python is installed you can execute where python in your cmd. This post does not seem to provide an answer to the question. Please either edit your answer, or just post it as a comment to the question. I'm not very familiar with Windows, but there in fact seems to be a where command which is supposed to be similar to which on Unixes.
In case you understand what the author is trying to say, you are free to edit and fix it. I can confirm where python works on cmd. Amit Gupta Amit Gupta 2, 2 2 gold badges 19 19 silver badges 33 33 bronze badges. Match n. Parse m. Peter Peter This would seem to miss globally-installed python instances. Yes seems i created a bug there. David 1, 3 3 gold badges 13 13 silver badges 29 29 bronze badges. Prashant Gonga Prashant Gonga 2 2 silver badges 6 6 bronze badges.
Suraj Rao Wingrider07 Wingrider07 11 1 1 bronze badge. Kos 4, 8 8 gold badges 32 32 silver badges 39 39 bronze badges. Ashwarya sharma Ashwarya sharma 11 3 3 bronze badges. Douglas Gilliland Douglas Gilliland 1. PV8 PV8 4, 3 3 gold badges 31 31 silver badges 61 61 bronze badges. There you can see all of the paths associated to where python, pip and other binaries are located that you call on command line.
Sign up or log in Sign up using Google. Sign up using Facebook. Sign up using Email and Password. Post as a guest Name. Email Required, but never shown. The Overflow Blog. Podcast Making Agile work for data science. Stack Gives Back
0コメント