gluap / pyduofern

GNU General Public License v2.0
40 stars 11 forks source link

ModuleNotFoundError #29

Closed Boby71 closed 3 years ago

Boby71 commented 3 years ago

I don't know what happened, but when I try to to start the script, I get the following error:

Traceback (most recent call last):
  File "/home/openhabian/.local/bin/duofern_cli.py", line 26, in <module>
    from pyduofern.duofern_stick import DuofernStickThreaded
ModuleNotFoundError: No module named 'pyduofern'

I'm an absolute noob in python, but when I try to install the package it looks fine:

openhabian@openHABianPi:/ $ pip3 install pyduofern
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Requirement already satisfied: pyduofern in /home/openhabian/.local/lib/python3.7/site-packages (0.34.1)
Requirement already satisfied: pyserial-asyncio in /home/openhabian/.local/lib/python3.7/site-packages (from pyduofern) (0.5)
Requirement already satisfied: pyserial in /home/openhabian/.local/lib/python3.7/site-packages (from pyduofern) (3.5)
openhabian@openHABianPi:/ $

Where's my mistake/problem? Thanks!

Boby71 commented 3 years ago

I used sudo to call python; after removing sudo everything was fine again

Boby71 commented 3 years ago

Also, take care that installing pyduofern using SUDO (sudo pip3 install pyduofern) - otherwise you could run into the same problem as well (Modulenotfounderror). It may depend your installation, but if you run into this error it's an easy task to check.

gluap commented 3 years ago

Let me add that whether sudo is required or not depends on the setup. A lot of people use virtualenvs / venvs to run python modules like this one. If a virtualenv/venv is used, always pip from the venv should be used.

Some people actually install third party modules in their OS, in this case sudo pipis the way to go (I'd always recommend working with venvs though, as does, for instance, the homeassistant core documentation).

Finally there's a third way in case only one user wants to use pyduofern from their standard interpreter but still not pollute the system python libraries: in this case using pip from the OS but with an extra --user as pip install --user will install the modules in the overlay directory for the currently active user. .local/bin etc...