packt-cli / Packt-Publishing-Free-Learning

Scripts that automatically claim and download free daily eBooks from https://www.packtpub.com/packt/offers/free-learning

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ImportError: No module named 'api'

SR-G opened this issue · comments

commented

On a fresh install with python 3.5.3 and by doing a pip install git+https://github.com/luk6xff/Packt-Publishing-Free-Learning.git@master, i then get the following error when starting packt-cli :

[ root@216d0038e1ed:/usr ]$ packt-cli 
Traceback (most recent call last):
  File "/usr/local/bin/packt-cli", line 7, in <module>
    from packtPublishingFreeEbook import packt_cli
  File "/usr/local/lib/python3.5/dist-packages/packtPublishingFreeEbook.py", line 16, in <module>
    from api import (
ImportError: No module named 'api'
[ root@216d0038e1ed:/usr ]$ python --version
Python 3.5.3
[ root@216d0038e1ed:/usr ]$ pip --version
pip 18.1 from /usr/local/lib/python3.5/dist-packages/pip (python 3.5)

Any idea ?

What is the output of pip install git+https://github.com/luk6xff/Packt-Publishing-Free-Learning.git@master command?

I suppose that it recognises the same version 1.0.0 and does not see the need to install it again - we can consider semantic versioning here (I was going to propose it anyway).

You may try to uninstall the package and install it again (pip uninstall packt && pip install git+https://github.com/luk6xff/Packt-Publishing-Free-Learning.git@master) or try adding --force-reinstall when installing. Does it help?

commented

The output of another "pip install" command was (and indeed nothing new was installed again) :

[ root@216d0038e1ed:/usr ]$ pip install git+https://github.com/luk6xff/Packt-Publishing-Free-Learning.git@master
Collecting git+https://github.com/luk6xff/Packt-Publishing-Free-Learning.git@master
  Cloning https://github.com/luk6xff/Packt-Publishing-Free-Learning.git (to revision master) to /tmp/pip-req-build-fcz2yov5
Requirement already satisfied (use --upgrade to upgrade): packt==1.0.0 from git+https://github.com/luk6xff/Packt-Publishing-Free-Learning.git@master in ./local/lib/python3.5/dist-packages
Requirement already satisfied: beautifulsoup4==4.6.3 in ./local/lib/python3.5/dist-packages (from packt==1.0.0) (4.6.3)
Requirement already satisfied: click==7.0 in ./local/lib/python3.5/dist-packages (from packt==1.0.0) (7.0)
Requirement already satisfied: google-api-python-client==1.6.3 in ./local/lib/python3.5/dist-packages (from packt==1.0.0) (1.6.3)
Requirement already satisfied: requests==2.20.0 in ./local/lib/python3.5/dist-packages (from packt==1.0.0) (2.20.0)
Requirement already satisfied: python-slugify==1.2.6 in ./local/lib/python3.5/dist-packages (from packt==1.0.0) (1.2.6)
Requirement already satisfied: oauth2client<5.0.0dev,>=1.5.0 in ./local/lib/python3.5/dist-packages (from google-api-python-client==1.6.3->packt==1.0.0) (4.1.3)
Requirement already satisfied: httplib2<1dev,>=0.9.2 in ./local/lib/python3.5/dist-packages (from google-api-python-client==1.6.3->packt==1.0.0) (0.12.1)
Requirement already satisfied: uritemplate<4dev,>=3.0.0 in ./local/lib/python3.5/dist-packages (from google-api-python-client==1.6.3->packt==1.0.0) (3.0.0)
Requirement already satisfied: six<2dev,>=1.6.1 in ./local/lib/python3.5/dist-packages (from google-api-python-client==1.6.3->packt==1.0.0) (1.12.0)
Requirement already satisfied: certifi>=2017.4.17 in ./local/lib/python3.5/dist-packages (from requests==2.20.0->packt==1.0.0) (2018.11.29)
Requirement already satisfied: chardet<3.1.0,>=3.0.2 in ./local/lib/python3.5/dist-packages (from requests==2.20.0->packt==1.0.0) (3.0.4)
Requirement already satisfied: idna<2.8,>=2.5 in ./local/lib/python3.5/dist-packages (from requests==2.20.0->packt==1.0.0) (2.7)
Requirement already satisfied: urllib3<1.25,>=1.21.1 in ./local/lib/python3.5/dist-packages (from requests==2.20.0->packt==1.0.0) (1.24.1)
Requirement already satisfied: Unidecode>=0.04.16 in ./local/lib/python3.5/dist-packages (from python-slugify==1.2.6->packt==1.0.0) (1.0.23)
Requirement already satisfied: pyasn1-modules>=0.0.5 in ./local/lib/python3.5/dist-packages (from oauth2client<5.0.0dev,>=1.5.0->google-api-python-client==1.6.3->packt==1.0.0) (0.2.4)
Requirement already satisfied: rsa>=3.1.4 in ./local/lib/python3.5/dist-packages (from oauth2client<5.0.0dev,>=1.5.0->google-api-python-client==1.6.3->packt==1.0.0) (4.0)
Requirement already satisfied: pyasn1>=0.1.7 in ./local/lib/python3.5/dist-packages (from oauth2client<5.0.0dev,>=1.5.0->google-api-python-client==1.6.3->packt==1.0.0) (0.4.5)
Building wheels for collected packages: packt
  Running setup.py bdist_wheel for packt ... done
  Stored in directory: /tmp/pip-ephem-wheel-cache-xhi3vbgz/wheels/f9/90/c0/c664938690a63922c94d859fd75b2f4e04435ef8d7eaa76771
Successfully built packt
You are using pip version 18.1, however version 19.0.3 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.

Indeed after uninstall and reinstall, it works.
As you have guessed, problem is probably indeed about the 1.0.0 version being already installed.

@luk6xff I've released two versions, first one on my commit fixing the script after Packt changed their website behaviour, the second on later fixes so the problem @SR-G encountered won't happen again if only we'll remember about frequent enough releases.

We could also think about uploading this script on PyPi so users will be able to install it running pip install packt instead of installing it from GitHub (they probably won't remember the command as well).

I'll close the issue as it seems to be resolved for now.