mega.py: cannot import name 'Mega' from 'mega'

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

About this issue

Most upvoted comments

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

I was having the same problem.

work for me thanks!

For me it worked using:

from mega.mega import Mega

Oh my god it worked! Thank you!

For me it worked using:

from mega.mega import Mega

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

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 <module> 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 <module> 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 <module> 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?

I was having the same problem.

Your python file name is probably mega.py Change it