Nanderty
Posts: 4
Joined: Sat Oct 20, 2018 8:04 pm

My Python 3 doesn't notice RPLCD is installed

Sat Oct 20, 2018 8:13 pm

error:
Traceback (most recent call last):
File "/home/pi/Desktop/lcdtest.py", line 2, in <module>
from RPLCD import CharLCD
ImportError: No module named 'RPLCD'
I already reinstalled it a few times and took the files in the same folder as the programm.

Code: Select all

from RPi import GPIO
from RPLCD import CharLCD

lcd = CharLCD(pin_rs=7, pin_e=11, pins_data=[21, 22, 23, 24],
              numbering_mode=GPIO.BOARD,
              cols=16, rows=2, dotsize=8,
              charmap='A02',
              auto_linebreaks=True)

lcd.write_string('Hello world')

DirkS
Posts: 9246
Joined: Tue Jun 19, 2012 9:46 pm
Location: Essex, UK

Re: My Python 3 doesn't notice RPLCD is installed

Sat Oct 20, 2018 10:06 pm

Nanderty wrote:
Sat Oct 20, 2018 8:13 pm
I already reinstalled it a few times
How exactly?

Did you install it for your version of Python (meaning Python 2 or 3)

Nanderty
Posts: 4
Joined: Sat Oct 20, 2018 8:04 pm

Re: My Python 3 doesn't notice RPLCD is installed

Sun Oct 21, 2018 6:12 pm

I installed it like this:
  • $ sudo pip install RPLCD

    And I tryed to use it with python 2 and 3 both.

DirkS
Posts: 9246
Joined: Tue Jun 19, 2012 9:46 pm
Location: Essex, UK

Re: My Python 3 doesn't notice RPLCD is installed

Sun Oct 21, 2018 7:05 pm

Nanderty wrote:
Sun Oct 21, 2018 6:12 pm
I installed it like this:
  • $ sudo pip install RPLCD

    And I tryed to use it with python 2 and 3 both.
For Python 3 you need to install it with

Code: Select all

sudo pip3 install RPLCD
Did you run your script from the command line or from e.g. Thonny, IDLE or something else?

BTW: remove any files you copied from the installed module to your script location. These will do more harm than good.
Last edited by DirkS on Mon Oct 22, 2018 1:08 pm, edited 1 time in total.

Nanderty
Posts: 4
Joined: Sat Oct 20, 2018 8:04 pm

Re: My Python 3 doesn't notice RPLCD is installed

Mon Oct 22, 2018 1:04 pm

Thanks for the help!
I ran the script in the python 3 IDlE shell.
I'll try your solution as soon sas possible.

Nanderty
Posts: 4
Joined: Sat Oct 20, 2018 8:04 pm

Re: My Python 3 doesn't notice RPLCD is installed

Mon Oct 22, 2018 1:16 pm

Got this error:
  • Exception:
    Traceback (most recent call last):
    File "/usr/lib/python3/dist-packages/pip/basecommand.py", line 122, in main
    status = self.run(options, args)
    File "/usr/lib/python3/dist-packages/pip/commands/install.py", line 269, in run
    InstallRequirement.from_line(name, None))
    File "/usr/lib/python3/dist-packages/pip/req.py", line 173, in from_line
    return cls(req, comes_from, url=url, prereleases=prereleases)
    File "/usr/lib/python3/dist-packages/pip/req.py", line 71, in __init__
    req = pkg_resources.Requirement.parse(req)
    File "/usr/lib/python3/dist-packages/pkg_resources.py", line 2793, in parse
    reqs = list(parse_requirements(s))
    File "/usr/lib/python3/dist-packages/pkg_resources.py", line 2721, in parse_requirements
    "version spec")
    File "/usr/lib/python3/dist-packages/pkg_resources.py", line 2686, in scan_list
    raise ValueError(msg, line, "at", line[p:])
    ValueError: ('Expected version spec in', 'RP:CD', 'at', ':CD')

    Storing debug log for failure in /root/.pip/pip.log
I didn't find a .pip in the /root dir.

DirkS
Posts: 9246
Joined: Tue Jun 19, 2012 9:46 pm
Location: Essex, UK

Re: My Python 3 doesn't notice RPLCD is installed

Mon Oct 22, 2018 1:21 pm

Nanderty wrote:
Mon Oct 22, 2018 1:16 pm
Got this error:
  • Exception:
    Traceback (most recent call last):
    File "/usr/lib/python3/dist-packages/pip/basecommand.py", line 122, in main
    status = self.run(options, args)
    File "/usr/lib/python3/dist-packages/pip/commands/install.py", line 269, in run
    InstallRequirement.from_line(name, None))
    File "/usr/lib/python3/dist-packages/pip/req.py", line 173, in from_line
    return cls(req, comes_from, url=url, prereleases=prereleases)
    File "/usr/lib/python3/dist-packages/pip/req.py", line 71, in __init__
    req = pkg_resources.Requirement.parse(req)
    File "/usr/lib/python3/dist-packages/pkg_resources.py", line 2793, in parse
    reqs = list(parse_requirements(s))
    File "/usr/lib/python3/dist-packages/pkg_resources.py", line 2721, in parse_requirements
    "version spec")
    File "/usr/lib/python3/dist-packages/pkg_resources.py", line 2686, in scan_list
    raise ValueError(msg, line, "at", line[p:])
    ValueError: ('Expected version spec in', 'RP:CD', 'at', ':CD')

    Storing debug log for failure in /root/.pip/pip.log
I didn't find a .pip in the /root dir.
Sorry, there was a typo in the command line (: instead of L, see corrected command above).
(I think you need root permissions to see / access the /root/.pip)

Return to “Python”