abertschi/postcards

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

Closed this issue · 3 comments

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.

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

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.

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