Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ImportError: cannot import name '_PosixFlavour' from 'pathlib' #27

Closed
yochananmarqos opened this issue Apr 30, 2024 · 6 comments
Closed

Comments

@yochananmarqos
Copy link

AUR package maintainer here. I've updated everything now that Python 3.12 is available in Arch, however...

Traceback (most recent call last):
  File "/usr/bin/cast_control", line 5, in <module>
    from cast_control.app.cli import cli
  File "/usr/lib/python3.12/site-packages/cast_control/app/cli.py", line 8, in <module>
    from .daemon import Args, MprisDaemon, get_daemon, get_daemon_from_args
  File "/usr/lib/python3.12/site-packages/cast_control/app/daemon.py", line 12, in <module>
    from .state import setup_logging
  File "/usr/lib/python3.12/site-packages/cast_control/app/state.py", line 10, in <module>
    from aiopath import AsyncPath
  File "/usr/lib/python3.12/site-packages/aiopath/__init__.py", line 2, in <module>
    from .path import AsyncPath, AsyncPurePath, AsyncWindowsPath, \
  File "/usr/lib/python3.12/site-packages/aiopath/path.py", line 10, in <module>
    from .flavours import _async_windows_flavour, _async_posix_flavour
  File "/usr/lib/python3.12/site-packages/aiopath/flavours.py", line 2, in <module>
    from pathlib import _PosixFlavour, _WindowsFlavour
ImportError: cannot import name '_PosixFlavour' from 'pathlib' (/usr/lib/python3.12/pathlib.py)
@GarthPS
Copy link

GarthPS commented May 4, 2024

+1

@mirsella
Copy link

mirsella commented May 8, 2024

same error.
maybe this can help hadialqattan/pycln#221 (they had the same issue)

@BanditSan
Copy link

same error. maybe this can help hadialqattan/pycln#221 (they had the same issue)

That is exactly what causes this issue. Installing aiopath v0.7.1+ fixes this problem.
Requested python-aiopath maintainer update this package.

@yochananmarqos
Copy link
Author

yochananmarqos commented May 24, 2024

I tried aiopath 0.7.1 and 0.7.6, now there's a different error:

❯ cast_control service connect
Traceback (most recent call last):
  File "/usr/bin/cast_control", line 8, in <module>
    sys.exit(cli())
             ^^^^^
  File "/usr/lib/python3.12/site-packages/click/core.py", line 1157, in __call__
    return self.main(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/site-packages/click/core.py", line 1078, in main
    rv = self.invoke(ctx)
         ^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/site-packages/click/core.py", line 1688, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/site-packages/click/core.py", line 1688, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/site-packages/click/core.py", line 1434, in invoke
    return ctx.invoke(self.callback, **ctx.params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/site-packages/click/core.py", line 783, in invoke
    return __callback(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/site-packages/cast_control/app/cli.py", line 208, in connect
    args.save()
  File "/usr/lib/python3.12/site-packages/cast_control/app/daemon.py", line 103, in save
    ARGS.write_bytes(dump)
  File "/usr/lib/python3.12/pathlib.py", line 1036, in write_bytes
    with self.open(mode='wb') as f:
         ^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/pathlib.py", line 1013, in open
    return io.open(self, mode, buffering, encoding, errors, newline)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
FileNotFoundError: [Errno 2] No such file or directory: '/home/yochanan/.local/state/cast_control/0.14.0/service-args.tmp'

@BanditSan
Copy link

@yochananmarqos this might be some other issue not related with aiopath. With aiopath 0.6.11 you get this:

$ cast_control --help
Traceback (most recent call last):
  File "/usr/bin/cast_control", line 5, in <module>
    from cast_control.app.cli import cli
  File "/usr/lib/python3.12/site-packages/cast_control/app/cli.py", line 8, in <module>
    from .daemon import Args, MprisDaemon, get_daemon, get_daemon_from_args
  File "/usr/lib/python3.12/site-packages/cast_control/app/daemon.py", line 12, in <module>
    from .state import setup_logging
  File "/usr/lib/python3.12/site-packages/cast_control/app/state.py", line 10, in <module>
    from aiopath import AsyncPath
  File "/usr/lib/python3.12/site-packages/aiopath/__init__.py", line 2, in <module>
    from .path import AsyncPath, AsyncPurePath, AsyncWindowsPath, \
  File "/usr/lib/python3.12/site-packages/aiopath/path.py", line 10, in <module>
    from .flavours import _async_windows_flavour, _async_posix_flavour
  File "/usr/lib/python3.12/site-packages/aiopath/flavours.py", line 2, in <module>
    from pathlib import _PosixFlavour, _WindowsFlavour
ImportError: cannot import name '_PosixFlavour' from 'pathlib' (/usr/lib/python3.12/pathlib.py)

With 0.7.1 and 0.7.6

$ cast_control --help
Usage: cast_control [OPTIONS] COMMAND [ARGS]...

  Control casting devices via Linux media controls and desktops.

  This daemon connects your casting device to the D-Bus media player interface
  (MPRIS).

  See https://github.com/alexdelorenzo/cast_control for more information.

Options:
  -L, --license  Show license and copyright information.
  -V, --version  Show version information.
  --help         Show this message and exit.

Commands:
  connect  Connect to a device and run the service in the foreground.
  service  Connect, disconnect or reconnect the background service to or...

@yochananmarqos
Copy link
Author

@BanditSan Yes, you're right. I manually created the ~/.local/state/cast_control/0.14.0/ folder and the files were able to be created. It seems to be attempting to work now.

Anyway, I've updated the python-aiopath AUR package to 0.7.6.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants