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

OS module import fails #130

Open
Wh1teStr1pe opened this issue Feb 12, 2022 · 9 comments
Open

OS module import fails #130

Wh1teStr1pe opened this issue Feb 12, 2022 · 9 comments

Comments

@Wh1teStr1pe
Copy link

Wh1teStr1pe commented Feb 12, 2022

image

Cannot import correctly anything from os.path module and cannot use its functions like path.exists()

@Tinche
Copy link
Owner

Tinche commented Feb 13, 2022

Ah, you're saying from aiofiles.os.path import exists doesn't work?

@Wh1teStr1pe
Copy link
Author

Wh1teStr1pe commented Feb 14, 2022

@Tinche yes, there was no way to import path from aiofiles.os and use its functions. I could fix it only by running pip install types-aiofiles

@realsuayip
Copy link

I had the same issue today. Installing types-aiofiles wouldn't help me though. Python 3.10.1

@cpvandehey
Copy link

Same thing. Seeing this in mypy:
error: Module has no attribute "os" [attr-defined]

@ehn-pkalinowski
Copy link

you need to
import aiofiles.os
I had to look into the sources to deduce it...

tarneaux added a commit to tarneaux/f.bain that referenced this issue May 28, 2023
When uploading a file, the worker was consistently exiting with the
following error:

```
[truncated]
  File "/app/app/routes/upload.py", line 93, in handle_upload
    await aiofiles.os.rename(
AttributeError: module 'aiofiles' has no attribute 'os'
[2023-05-28 14:07:27 +0000] [14] [ERROR] closing handshake failed
```

Fixed by importing it separately as advised in this issue:
Tinche/aiofiles#130
@xhy2008
Copy link

xhy2008 commented Jan 22, 2024

import aiofiles.os
Traceback (most recent call last): File "", line 1, in
File "/data/data/com.termux/files/home/aiofiles-23.2.1/src/aiofiles/os.py", line 41, in link = wrap(os.link)
^^^^^^^ AttributeError: module 'os' has no attribute 'link'. Did you mean: 'unlink'?

I got this error.
I tried to change a version,but it didn't work.

@n-ce
Copy link

n-ce commented Mar 31, 2024

I got this error. I tried to change a version,but it didn't work.

Getting the same error.

@Wh1teStr1pe
Copy link
Author

Wh1teStr1pe commented Apr 1, 2024

@xhy2008 @n-ce

try this
from aiofiles import os as aos

@n-ce
Copy link

n-ce commented Apr 1, 2024

@xhy2008 @n-ce

try this from aiofiles import os as aos

I tried to remove the link = wrap(os.link) line from os.py yesterday and it worked. I also learned that this is a fixed issue but not released yet.

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

7 participants