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

pyinstaller error : ModuleNotFoundError: No module named 'mmcv._ext' #854

Closed
wongyufei opened this issue Sep 4, 2021 · 17 comments
Closed
Assignees

Comments

@wongyufei
Copy link

The plantform is win10, I install mmcv-full 1.1.5 for mmseg. It works well when I run main.py in pycharm.
However, after using pyinstaller package it a exe. It wrongs! ModuleNotFoundError: No module named 'mmcv._ext'

Here are the details:

Traceback (most recent call last):
File "main.py", line 15, in
File "PyInstaller\loader\pyimod03_importers.py", line 546, in exec_module
File "mmseg\apis_init_.py", line 1, in
File "PyInstaller\loader\pyimod03_importers.py", line 546, in exec_module
File "mmseg\apis\inference.py", line 8, in
File "PyInstaller\loader\pyimod03_importers.py", line 546, in exec_module
File "mmseg\models_init_.py", line 1, in
File "PyInstaller\loader\pyimod03_importers.py", line 546, in exec_module
File "mmseg\models\backbones_init_.py", line 2, in
File "PyInstaller\loader\pyimod03_importers.py", line 546, in exec_module
File "mmseg\models\backbones\fast_scnn.py", line 7, in
File "PyInstaller\loader\pyimod03_importers.py", line 546, in exec_module
File "mmseg\models\decode_heads_init_.py", line 16, in
File "PyInstaller\loader\pyimod03_importers.py", line 546, in exec_module
File "mmseg\models\decode_heads\point_head.py", line 6, in
File "PyInstaller\loader\pyimod03_importers.py", line 546, in exec_module
File "mmcv\ops_init_.py", line 1, in
File "PyInstaller\loader\pyimod03_importers.py", line 546, in exec_module
File "mmcv\ops\bbox.py", line 3, in
File "mmcv\utils\ext_loader.py", line 11, in load_ext
File "importlib_init_.py", line 126, in import_module
ModuleNotFoundError: No module named 'mmcv._ext'

@MengzhangLI
Copy link
Contributor

Hi, I guess it is caused by version conflict between MMSegmentation and MMCV or installation failure of MMCV.

Please check out here: open-mmlab/mmdetection#3765, open-mmlab/mmdetection#3271

I suggest you uninstall MMCV and install correct MMCV-full again.

Best,

@MengzhangLI MengzhangLI self-assigned this Sep 4, 2021
@wongyufei
Copy link
Author

I install mmcv-full==1.1.5 mmsegmentation==0.12.0, I think it is reasonable. It works well when I run this code with pycharm, but it wrong after using pyinstaller pack it up.

@MengzhangLI
Copy link
Contributor

I install mmcv-full==1.1.5 mmsegmentation==0.12.0, I think it is reasonable. It works well when I run this code with pycharm, but it wrong after using pyinstaller pack it up.

OK, does it works well if you use terminal ?

@wongyufei
Copy link
Author

Yes,it works well

@MengzhangLI
Copy link
Contributor

OK, I will write down this issue and discuss with my colleagues.

Because it has something to do with PyInstaller, which beyond codebase itself, please wait for a couple of days.

Best,

@wongyufei
Copy link
Author

Thanks for your reply!

@MengzhangLI
Copy link
Contributor

Hi, did you check whether the environment is the same? I mean the pyinstaller uses same environment with terminal and pycharm?

@wongyufei
Copy link
Author

wongyufei commented Sep 8, 2021 via email

@MengzhangLI
Copy link
Contributor

OK, got it. Please wait for some days.

Best,

@yldcs
Copy link

yldcs commented Sep 8, 2021

I got the same problem. Do you have fixed it ?

@wongyufei
Copy link
Author

wongyufei commented Sep 8, 2021 via email

@majnas
Copy link

majnas commented Sep 9, 2021

Package Version Location


addict 2.4.0
cycler 0.10.0
kiwisolver 1.3.2
matplotlib 3.4.3
mmcv 1.3.12
mmcv-full 1.3.12
mmsegmentation 0.17.0 /mnt/project//semantic_segmentation/code/mmsegmentation
numpy 1.21.2
opencv-python 4.5.3.56
packaging 21.0
Pillow 8.3.2
pip 20.0.2
pkg-resources 0.0.0
prettytable 2.2.0
pyparsing 2.4.7
python-dateutil 2.8.2
PyYAML 5.4.1
setuptools 44.0.0
six 1.16.0
torch 1.8.1
torchaudio 0.8.1
torchvision 0.9.1
typing-extensions 3.10.0.2
wcwidth 0.2.5
wheel 0.34.2
yapf 0.31.0

after changing mmcv-full from 1.3.7 to 1.3.12 problem solved!

pip uninstall mmcv
pip uninstall mmcv-full
pip install mmcv-full==1.3.12
pip install mmcv

@wongyufei
Copy link
Author

wongyufei commented Sep 9, 2021 via email

@maisonhai3
Copy link

maisonhai3 commented Dec 7, 2021

Try this command:
pyinstaller --hidden-import=mmcv._ext --hidden-import torchvision --onefile our_python_file.py

Explain

We faced this issue exactly. Here my collage solution:

  • While running pyinstaller, add --hidden-import with the path to your mmcv.
  • While installing PyTorch, we only want to use CPU version, so in homepage of PyTorch, we use pip-cpu-version install command.

Our platform:

  • Windows 11,
  • GPU 1080Ti.
  • Anaconda

If you want to package with PyTorch GPU version, I am not sure if this method works, but worth a try.

@wongyufei
Copy link
Author

wongyufei commented Dec 7, 2021 via email

@wydonglove
Copy link

@wongyufei @MengzhangLI Do you have fixed it ? thanks for your reply

@xiehou-design
Copy link

I also meet this problem. Do you have fix it? Thanks.

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