Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

user site-package directory

Tags:

python

pip

pdb

I want to know how '~/.local/lib/python2.7/site-packages' get into my 'sys.path'.

Is it defined by PEP 370 or modified by pip(I install package with --user option)?

I also found out that this entry disappears if I move '~/.local/lib/python2.7/site-packages' to '~/.local/lib/python2.7/site-packages.bak'.

I add this function Ad-hoc data breakpoints to .pystartup, but nothing changes.

Any one have any idea about this?

like image 285
schemacs Avatar asked Nov 02 '22 10:11

schemacs


1 Answers

It comes via the site module, which is imported by default by the interpreter unless you give it the -S option. (Do that, and you'll see it's no longer added, along with other things.)

Specifically, it's derived from the site module's notion of a "user base" directory, which defaults to ~/.local on POSIX systems. That, in turn, is handled by the sysconfig module, as the userbase config variable.

See the documentation for the site and sysconfig modules for more details.

The reason your data breakpoints don't work is probably just because site is imported before your .pystartup runs.

like image 104
Dolda2000 Avatar answered Nov 12 '22 18:11

Dolda2000