abertschi / postcards

A CLI for the Swiss Postcard Creator :postbox:
https://abertschi.ch/blog/2022/receiving-postcards/
MIT License
36 stars 8 forks source link

AttributError: 'module' object has no attribute 'request' #24

Closed GruberMischa closed 6 years ago

GruberMischa commented 6 years ago

When i execute the following command, I get an AttributeError: postcards send --config config.json --picture https://i.redd.it/lwozsd9y55q01.jpg --message "Hallo"

instance (INFO): reading config file at C:\Users\<<user>>\PostCards\config.json
instance (INFO): checking for valid accounts
instance (INFO): account <<user>> is valid
Traceback (most recent call last):
  File "c:\python27\lib\runpy.py", line 174, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
  File "c:\python27\lib\runpy.py", line 72, in _run_code
    exec code in run_globals
  File "C:\Python27\Scripts\postcards.exe\__main__.py", line 9, in <module>
  File "c:\python27\lib\site-packages\postcards\postcards.py", line 510, in main
    p.main(sys.argv)
  File "c:\python27\lib\site-packages\postcards\postcards.py", line 52, in main
    self.do_command_send(args)
  File "c:\python27\lib\site-packages\postcards\postcards.py", line 112, in do_command_send
    picture_stream=self._read_picture(args.picture) if args.picture else None,
  File "c:\python27\lib\site-packages\postcards\postcards.py", line 291, in _read_picture
    request = urllib.request.Request(location, None, headers)
AttributeError: 'module' object has no attribute 'request'

I'm running it on a Windows 10 machine, but I also tried it on a Raspberry Pi with Rasbian. But there I couldn't even install it, neither with pip or installing it from the source.

abertschi commented 6 years ago

You are running the script with Python2 but Python3 is needed.

abertschi commented 6 years ago

As for your Rasbian issue, what error do you get? As with all Python packages, it is good advice to create a new (python3) virtual environment and install the package within there.

GruberMischa commented 6 years ago

Ok didn't see it was mentioned somewhere. Now it work on both machines. On Rasbian currently with the virtual environment. So the next thing for me to do , is to integrate it with Home Assistant 😄 Thanks