mkb79 / audible-cli

A command line interface for audible package. With the cli you can download your Audible books, cover, chapter files.
GNU Affero General Public License v3.0
423 stars 45 forks source link

ModuleNotFoundError: No module named 'pkg_resources' #188

Closed StefanLobbenmeier closed 3 months ago

StefanLobbenmeier commented 4 months ago

I installed this via pipx on macOS 14.4.

brew install pipx

pipx install audible-cli

pipx ensurepath

audible
Traceback (most recent call last):
  File "~/.local/bin/audible", line 7, in <module>
    from audible_cli import main
  File "~/Library/Application Support/pipx/venvs/audible-cli/lib/python3.12/site-packages/audible_cli/__init__.py", line 5, in <module>
    from .cli import main, quickstart
  File "~/Library/Application Support/pipx/venvs/audible-cli/lib/python3.12/site-packages/audible_cli/cli.py", line 3, in <module>
    from pkg_resources import iter_entry_points
ModuleNotFoundError: No module named 'pkg_resources'

To solve this I had to add setuptools:

pipx runpip audible-cli install setuptools
Collecting setuptools
  Using cached setuptools-69.2.0-py3-none-any.whl.metadata (6.3 kB)
Using cached setuptools-69.2.0-py3-none-any.whl (821 kB)
Installing collected packages: setuptools
Successfully installed setuptools-69.2.0

And now the audible command works 😄

FYI this is the requirements that were installed by pipx (before I ran the additional install):

pipx runpip audible-cli list
Package        Version
-------------- --------
aiofiles       23.2.1
anyio          4.3.0
audible        0.8.2
audible-cli    0.2.6
beautifulsoup4 4.12.3
certifi        2024.2.2
click          8.1.7
h11            0.14.0
httpcore       0.16.3
httpx          0.23.3
idna           3.6
packaging      24.0
pbkdf2         1.3
pillow         10.2.0
pip            24.0
prompt-toolkit 3.0.36
pyaes          1.6.1
pyasn1         0.5.1
questionary    2.0.1
rfc3986        1.5.0
rsa            4.9
sniffio        1.3.1
soupsieve      2.5
tabulate       0.9.0
toml           0.10.2
tqdm           4.66.2
wcwidth        0.2.13

I suppose fixing this is just adding setuptools to the requirements?

mkb79 commented 4 months ago

Thank you for this information. I am already aware of this problem. setuptools should actually be installed in most Python environments. Therefore, the error should only occur in rare cases. That's also why I hadn't noticed it until recently.

To solve this problem with pipx, you can run pipx inject audible-cli setuptools too. But I will include setuptools in the list of dependencies in the next release. In the meantime, I'll keep this issue open to make it easier for everyone to find.

Best regards

mkb79 commented 3 months ago

The master branch now includes a fix for this issue. I'll close this issue, when the fix will be released.

mkb79 commented 3 months ago

v0.3.0 is now out

StefanLobbenmeier commented 3 months ago

just to confirm, I just ran pipx uninstall audible-cli and pipx install audible-cli and received

audible --version
audible-cli, version 0.3.1 (up-to-date)

Surprisingly pipx runpip audible-cli list does not include setuptools, but it seems to work nonetheless.

StefanLobbenmeier commented 3 months ago

using importlib.metadata over setuptools (pkg_resources) to get entrypoints

nevermind, it is no longer needed 😄 so all good

mkb79 commented 3 months ago

Thank you for this information. Some user reported, that they have issues downloading aax files. Do you have them too?

StefanLobbenmeier commented 3 months ago

Yeah looks like I have the same issue:

audible -v DEBUG download -a B...X --aax
debug: Audible-cli version: 0.3.1
debug: App dir: ~/.audible
debug: Plugin dir: ~/.audible/plugins
debug: Using asyncio.run ...
debug: Config loaded from config.toml
debug: Auth file audible.json for profile audible loaded.

No new files downloaded.

Adding a c at the end to download an aaxc file works

StefanLobbenmeier commented 3 months ago

it is a fairly new audiobook, I suspect it might not have aac. But using --all I can download some audiobooks:

error: 5.14 - Der Orden des Phönix (Teil 1) is not downloadable in AAX format
Nicht_einschlafen-LC_128_44100_stereo.aax:  25%|████████████▊                                       | 7.04M/28.6M [00:04<00:05, 4.49MB/s]
mkb79 commented 3 months ago

I've found the reason for the aax issue. Fix is on the way. In the meantime you can use --timeout 0. But you have to wait 1 to 2 minutes. The Amazon server have some trouble with head requests. Get request to the same URI are answered in some milliseconds.

PS: Schönes Audiobuch. Das gab es glaube ich mal kostenlos?

StefanLobbenmeier commented 3 months ago

PS: Schönes Audiobuch. Das gab es glaube ich mal kostenlos?

yeah exactly, most of my library is just audiobooks that I got for free and never listened to 😄 but if you can recommend it I will give it a go

(it was free last year it seems: https://www.mydealz.de/search?q=nicht%20einschlafen) image