Score:0

'pip3 freeze' and 'sudo pip3 freeze' are different

vn flag

On my system (Raspbian Buster, raspberry pi CM4), packages installed with 'pip3 install ' are not available when I run 'sudo python3':

$ pip3 freeze |grep numpy
numpy==1.21.5
$ sudo python3
Python 3.7.3 (default, Jan 22 2021, 20:04:44)
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'numpy'

There is also a difference in the output of 'pip3 freeze' and 'sudo pip3 freeze':

$ pip3 freeze |grep numpy
numpy==1.21.5
$ sudo pip3 freeze |grep numpy
<no output>

Both run from the same executable ('/usr/bin/pip3' and '/usr/bin/python3') so how come the environments of these 2 users are different?

Is there a way to use 'sudo python3' and still get the packages installed with the user environment?

p.s: I know about virtualenv, but I would prefer not to use it if possible

Score:0
es flag

compare output of

python3 -m site

and

sudo python3 -m site

you can find an absolute path to module files with a command

python -c "import numpy as _; print(_.__path__)"
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.