Where shall I put my self-written Python packages? -
is there canonical location put self-written packages? own search yielded blog post where put version-independent pure python packages , so question canonical location under linux, while working on windows.
my use case able import own packages during ipython session site-package, no matter in working directory started session. in matlab, corresponding folder example c:/users/ojdo/documents/matlab
.
import mypackage mp mp.awesomefunction() ...
thanks two additional links, found not intended answer question, solution more , - ironically - explained in first search result, obfuscated version-(in)dependent site-package lingo.
answer original question
i wanted know if there canonical (as in "default") location self-written packages. , exists:
>>> import site >>> site.user_site 'c:\\users\\ojdo\\appdata\\roaming\\python\\python27\\site-packages'
the docs on user scheme package installation state folder - if exists - automatically added sys.path
.
custom directory own packages
- create directory anywhere, e.g.
c:\users\ojdo\documents\python\libs
. - add file
sitecustomize.py
site-packages folder of python installation, i.e. inc:\python27\lib\site-packages
(for users) orsite.user_site
(for single user). this file filled following code:
import site site.addsitedir(r'c:\users\ojdo\any\folder\you\like\libs')
- voilĂ , new directory automatically added
sys.path
in every (i)python session.
how works: package site, automatically imported during every start of python, tries import package sitecustomize
custom package path modifications. in case, dummy package consists of script adds personal package folder python path.
Comments
Post a Comment