Anaconda library path

1,526 views
Skip to first unread message

Jay Wang

unread,
Sep 22, 2017, 1:57:32 PM9/22/17
to comphys
On Windows 10, the default library path is (jwang=your user name)
"C:\\Users\\jwang\\Anaconda3\\lib"

Find out yours with the following code in Jupyter:
import sys
sys.path

Please post where it is if you use Mac or Linux.

nmoniz2

unread,
Sep 25, 2017, 9:14:43 PM9/25/17
to comphys
For Mac OS, the default library path is:

/Users/username/anaconda/lib/python_version

For Linux (depending on distro), it's most likely very similar (I haven't explicitly tested this):

~/username/anaconda/lib/pyton_version 

In the above, replace "username" with your own personal user name and "python_version" with your own python version (i.e python2.7). 

The same commands as posted below will identify your own personal default installation path.

Jay Wang

unread,
Sep 28, 2017, 11:01:27 AM9/28/17
to comphys
You can add your own path to the existing ones. For example, if you want to add "C:\comphys\lib" in Windows, do this:
import sys
sys.path.append(
"C:\\comphys\\lib")
sys.path

You should see it in the last entry of the path. Note the double backslashes.
In Linux including
our remote Jupyter server, it should be something like
sys.path.append("./comphys/lib") (assuming Jupyter is started from current folder)

Now put any library file in the lib folder, and your program should be able to find it. Because this holds per program, you must append this at the beginning of every program. Maybe there is a way to do so permanently.

Jay Wang

unread,
Mar 27, 2018, 12:02:59 PM3/27/18
to com...@googlegroups.com
A more permanent fix is this. See http://www.faculty.umassd.edu/j.wang/book/libs/libs.htm and https://stackoverflow.com/questions/37006114/anaconda-permanently-include-external-packages-like-in-pythonpath.
 On Anaconda, library files may be placed in "C:\Users\yourname\Anaconda3\lib" on Windows 10 for example. But it is tidier to put them in one folder in site-packages as "C:\Users\yourname\Anaconda3\lib\site-packages\compy". To do so, create a file compy.pth containing the folder path in quotes and place it and lib files in paths as follows:
C:\Users\yourname\Anaconda3\lib\site-packages\compy.pth
C:\Users\yourname\Anaconda3\lib\site-packages\compy\ode.py
. . . \xyz.py
Reply all
Reply to author
Forward
0 new messages