2

I have a Python script I would like to run in a Docker container but it stops with error:

 File "main.py", line 1, in <module>
   from pushover import init, Client
ImportError: cannot import name 'init' from 'pushover' (/usr/local/lib/python3.8/dist-packages/pushover/__init__.py)

In PyCharm the script runs fine. The Dockerfile looks like this:

RUN apt-get update -y && apt-get install git python3 python3-pip -y; \ 
   git clone https://(path to my script) ; \
   pip3 install pushover
WORKDIR "/FNotify/"
CMD  python3 main.py; 

and my imports in the script look like this:

from pushover import init, Client
import os
from time import sleep
  • [That library's source](https://github.com/laprice/pushover/blob/master/pushover/pushover.py) doesn't suggest it has a function named `init`. Does the same setup work in a non-Docker virtual environment? – David Maze Dec 09 '20 at 21:15
  • @DavidMaze Yes, on my Windows environment with pyCharm it works flawless. – HardwareFuture Dec 09 '20 at 21:26

1 Answers1

0

You make confuse for wrong package & correct package, so what you should install is next:

pip3 install python-pushover

The result:

# python3
Python 3.6.7 (default, Oct 22 2018, 11:32:17)
[GCC 8.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from pushover import init
>>>

Also, the python-pushover webpage gives the example usage which same as yours:

from pushover import init, Client

init("<token>")
Client("<user-key>").send_message("Hello!", title="Hello")
atline
  • 28,355
  • 16
  • 77
  • 113