odwyersoftware / mega.py

Python library for the https://mega.nz/ API.
https://github.com/odwyersoftware/mega.py
Apache License 2.0
347 stars 165 forks source link

cannot import name 'Mega' from 'mega' #26

Open BrianZbr opened 3 years ago

BrianZbr commented 3 years ago

I just created a new Ubuntu 20.4.1 VM on Windows 10 / Hyper-V and I ran pip3 install mega.

When I run from mega import Mega in a Python 3.8.2 interpreter I get ImportError: cannot import name 'Mega' from 'mega' (/home/dowcet/.local/lib/python3.8/site-packages/mega/__init__.py\

I have confirmed that path /home/dowcet/.local/lib/python3.8/site-packages/mega/__init__.py exists, and it contains both __init__.py and mega.py

predict-woo commented 3 years ago

Your python file name is probably mega.py Change it

BrianZbr commented 3 years ago

No, the only file anywhere in ~/ with that name is /home/dowcet/.local/lib/python3.8/site-packages/mega/mega.py

agentmerlot1412 commented 3 years ago

Same issue here.

Aviglik91 commented 3 years ago

Hi , I think you installed the wrong pip package. you should have installed : pip3 install mega.py I suggest removing the old package like this : pip3 uninstall mega and then: pip3 install mega.py hope it helps

sahilkundu commented 3 years ago

hello where run this command " from mega import Mega " , in the terminal or other folder. Please tell me

Tatuck commented 3 years ago

hello where run this command " from mega import Mega " , in the terminal or other folder. Please tell me

@sahilkundu That is not a command, that is a line of code which imports Mega in a Python project. You need to create a file, set its extension to .py and import it like that (from mega import Mega). Then write all the code you want. I hope it helps.

Prograb commented 3 years ago

Hi , I think you installed the wrong pip package. you should have installed : pip3 install mega.py I suggest removing the old package like this : pip3 uninstall mega and then: pip3 install mega.py hope it helps

nah still not working

rstudiocode commented 2 years ago

I have the same probem

tejaskj commented 2 years ago

I was having the same problem.

santosadrian commented 1 year ago

I have a similar issue:

[/root/mirrorbot]:# ./start.sh /bin/sh: 1: gunicorn: not found Bad command line: You cannot use -d (or --daemon): qBittorrent is already running for this user. Run application with -h option to read about command line parameters. 2022-09-24 12:53:57,453 - bot - INFO - Generating USER_SESSION_STRING 2022-09-24 12:53:57,454 - bot - INFO - Generating TELEGRAPH_TOKEN using 'zqBukQPu' name 2022-09-24 12:53:57,689 - root - WARNING - MEGA Credentials not provided! 2022-09-24 12:53:57,690 - root - WARNING - BASE_URL_OF_BOT not provided! Traceback (most recent call last): File "/root/anaconda3/lib/python3.7/runpy.py", line 193, in _run_module_as_main "main", mod_spec) File "/root/anaconda3/lib/python3.7/runpy.py", line 85, in _run_code exec(code, run_globals) File "/root/mirrorbot/bot/main.py", line 20, in from .modules import authorize, list, cancel_mirror, mirror_status, mirror, clone, watch, shell, eval, torrent_search, delete, speedtest, count, leech_settings File "/root/mirrorbot/bot/modules/mirror.py", line 25, in from bot.helper.mirror_utils.download_utils.mega_downloader import MegaDownloadHelper File "/root/mirrorbot/bot/helper/mirror_utils/download_utils/mega_downloader.py", line 3, in from mega import (MegaApi, MegaListener, MegaRequest, MegaTransfer, MegaError) ImportError: cannot import name 'MegaApi' from 'mega' (/root/anaconda3/lib/python3.7/site-packages/mega/init.py)

Itried everything, any idea?

rcolman05 commented 1 year ago

For me it worked using:

from mega.mega import Mega

Prograb commented 1 year ago

For me it worked using:

from mega.mega import Mega

Oh my god it worked! Thank you!

Rembrant777 commented 1 year ago

I was having the same problem.

work for me thanks!

addreeh commented 1 year ago

I'm having an issue, when I tried to run the program gives me this error, I tried everything u said in this post:

Traceback (most recent call last): File "c:\Users\Administrator\Desktop\saot\pedro.py", line 1, in <module> from mega.mega import Mega File "C:\Users\Administrator\AppData\Local\Programs\Python\Python311\Lib\site-packages\mega\__init__.py", line 1, in <module> from .mega import Mega # noqa ^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\Administrator\AppData\Local\Programs\Python\Python311\Lib\site-packages\mega\mega.py", line 18, in <module> from tenacity import retry, wait_exponential, retry_if_exception_type File "C:\Users\Administrator\AppData\Local\Programs\Python\Python311\Lib\site-packages\tenacity\__init__.py", line 451, in <module> from tenacity._asyncio import AsyncRetrying File "C:\Users\Administrator\AppData\Local\Programs\Python\Python311\Lib\site-packages\tenacity\_asyncio.py", line 33, in <module> class AsyncRetrying(BaseRetrying): File "C:\Users\Administrator\AppData\Local\Programs\Python\Python311\Lib\site-packages\tenacity\_asyncio.py", line 41, in AsyncRetrying @asyncio.coroutine ^^^^^^^^^^^^^^^^^ AttributeError: module 'asyncio' has no attribute 'coroutine'. Did you mean: 'coroutines'?

Timtaran commented 1 year ago

I have same problem

marcin-bo commented 1 year ago

I'm having an issue, when I tried to run the program gives me this error, I tried everything u said in this post:

Traceback (most recent call last): File "c:\Users\Administrator\Desktop\saot\pedro.py", line 1, in <module> from mega.mega import Mega File "C:\Users\Administrator\AppData\Local\Programs\Python\Python311\Lib\site-packages\mega\__init__.py", line 1, in <module> from .mega import Mega # noqa ^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\Administrator\AppData\Local\Programs\Python\Python311\Lib\site-packages\mega\mega.py", line 18, in <module> from tenacity import retry, wait_exponential, retry_if_exception_type File "C:\Users\Administrator\AppData\Local\Programs\Python\Python311\Lib\site-packages\tenacity\__init__.py", line 451, in <module> from tenacity._asyncio import AsyncRetrying File "C:\Users\Administrator\AppData\Local\Programs\Python\Python311\Lib\site-packages\tenacity\_asyncio.py", line 33, in <module> class AsyncRetrying(BaseRetrying): File "C:\Users\Administrator\AppData\Local\Programs\Python\Python311\Lib\site-packages\tenacity\_asyncio.py", line 41, in AsyncRetrying @asyncio.coroutine ^^^^^^^^^^^^^^^^^ AttributeError: module 'asyncio' has no attribute 'coroutine'. Did you mean: 'coroutines'?

Try to upgrade tenacity.

pip install --upgrade tenacity
obervinov commented 1 year ago

I'm having an issue, when I tried to run the program gives me this error, I tried everything u said in this post: Traceback (most recent call last): File "c:\Users\Administrator\Desktop\saot\pedro.py", line 1, in from mega.mega import Mega File "C:\Users\Administrator\AppData\Local\Programs\Python\Python311\Lib\site-packages\mega__init.py", line 1, in from .mega import Mega # noqa ^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\Administrator\AppData\Local\Programs\Python\Python311\Lib\site-packages\mega\mega.py", line 18, in from tenacity import retry, wait_exponential, retry_if_exception_type File "C:\Users\Administrator\AppData\Local\Programs\Python\Python311\Lib\site-packages\tenacity\init__.py", line 451, in from tenacity._asyncio import AsyncRetrying File "C:\Users\Administrator\AppData\Local\Programs\Python\Python311\Lib\site-packages\tenacity_asyncio.py", line 33, in class AsyncRetrying(BaseRetrying): File "C:\Users\Administrator\AppData\Local\Programs\Python\Python311\Lib\site-packages\tenacity_asyncio.py", line 41, in AsyncRetrying @asyncio.coroutine ^^^^^^^^^^^^^^^^^ AttributeError: module 'asyncio' has no attribute 'coroutine'. Did you mean: 'coroutines'?

For me, it only works with python:3.10.7. Any version higher than 3.10.7 causes me the same error.

LxOnTop commented 1 year ago

I'm having an issue, when I tried to run the program gives me this error, I tried everything u said in this post: Traceback (most recent call last): File "c:\Users\Administrator\Desktop\saot\pedro.py", line 1, in <module> from mega.mega import Mega File "C:\Users\Administrator\AppData\Local\Programs\Python\Python311\Lib\site-packages\mega\__init__.py", line 1, in <module> from .mega import Mega # noqa ^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\Administrator\AppData\Local\Programs\Python\Python311\Lib\site-packages\mega\mega.py", line 18, in <module> from tenacity import retry, wait_exponential, retry_if_exception_type File "C:\Users\Administrator\AppData\Local\Programs\Python\Python311\Lib\site-packages\tenacity\__init__.py", line 451, in <module> from tenacity._asyncio import AsyncRetrying File "C:\Users\Administrator\AppData\Local\Programs\Python\Python311\Lib\site-packages\tenacity\_asyncio.py", line 33, in <module> class AsyncRetrying(BaseRetrying): File "C:\Users\Administrator\AppData\Local\Programs\Python\Python311\Lib\site-packages\tenacity\_asyncio.py", line 41, in AsyncRetrying @asyncio.coroutine ^^^^^^^^^^^^^^^^^ AttributeError: module 'asyncio' has no attribute 'coroutine'. Did you mean: 'coroutines'?

Try to upgrade tenacity.

pip install --upgrade tenacity

W Mann Worked God Bles U

nnilayy commented 2 months ago

Traceback (most recent call last): File "c:\Users\Administrator\Desktop\saot\pedro.py", line 1, in from mega.mega import Mega File "C:\Users\Administrator\AppData\Local\Programs\Python\Python311\Lib\site-packages\mega__init.py", line 1, in from .mega import Mega # noqa ^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\Administrator\AppData\Local\Programs\Python\Python311\Lib\site-packages\mega\mega.py", line 18, in from tenacity import retry, wait_exponential, retry_if_exception_type File "C:\Users\Administrator\AppData\Local\Programs\Python\Python311\Lib\site-packages\tenacity\init__.py", line 451, in from tenacity._asyncio import AsyncRetrying File "C:\Users\Administrator\AppData\Local\Programs\Python\Python311\Lib\site-packages\tenacity_asyncio.py", line 33, in class AsyncRetrying(BaseRetrying): File "C:\Users\Administrator\AppData\Local\Programs\Python\Python311\Lib\site-packages\tenacity_asyncio.py", line 41, in AsyncRetrying @asyncio.coroutine ^^^^^^^^^^^^^^^^^ AttributeError: module 'asyncio' has no attribute 'coroutine'. Did you mean: 'coroutines'?

If someone is still facing the coroutine error, I encountered the same error with python 3.11 version specifically, python 3.11.4, I tried the following code

from mega import Mega 
mega = Mega()
email = 'your_emailk@gmail.com'
password = 'your_password'
mega.login(email, password) 

I got the same error faced by @addreeh above. But when I switched the python version from python 3.11 to python 3.10 the issues were resolved and the code was working fine. My specific python 3.10 version was python 3.10.11.

Hope this helps 😊.