Roland Mueller <roland.em0...@googlemail.com> wrote: > Hello, > > pe 23. heinäk. 2021 klo 21.44 Chris Green (c...@isbd.net) kirjoitti: > > > This isn't a question about how to set PYTHONPATH so that Python code > > can find imported modules, it's about what is a sensible layout for > > one's home directory - i.e. where to put Python modules. > > > > I'm running Linux and have a number of Python modules that are only > > used by my own code. My top level Python code is all in ~/bin. I'd > > prefer to separate the modules so that they don't clutter the name > > space. > > > > Currently I have my Python modules in a subdirectory of ~/bin and my > > Python path is set as:- > > > > PYTHONPATH=/home/chris/bin/pymods > > > > Is this a reasonable approach? Is there a 'standard' name for the > > directory containing modules, or a standard place for it? (I don't > > mean a system-wide standard place, I mean a 'my' standard place). > > > > Under recent Linux distros there is $HOME/.local/ containing bin and lib > directories. May be it's ok to use this for user-specific python settings > under Linux. > > E.g. in .bashrc > export PYTHONPATH=$HOME/.local/python > > Result can be checked then in Python: > python > >>> import sys > >>> sys.path > ['', '/home/someuser/.local/lib/python', '/usr/lib64/python39.zip', > '/usr/lib64/python3.9', '/usr/lib64/python3.9/lib-dynload', > '/usr/local/lib/python3.9/site-packages', > '/usr/lib64/python3.9/site-packages', '/usr/lib/python3.9/site-packages'] > That's certainly a possibility, thanks.
-- Chris Green · -- https://mail.python.org/mailman/listinfo/python-list