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

ModuleNotFoundError: No module named 'numpy.random.common' #4363

Closed
ebonat opened this issue Aug 7, 2019 · 15 comments
Closed

ModuleNotFoundError: No module named 'numpy.random.common' #4363

ebonat opened this issue Aug 7, 2019 · 15 comments
Labels
area:hooks Caused by or effecting some hook solution:won't fix Resolved: Maintainers will not fix this.

Comments

@ebonat
Copy link

ebonat commented Aug 7, 2019

With:

  • pyinstaller 4.0.dev0
  • python 3.6.7
  • windows 7

python file

import sys
from PyQt5 import QtCore, QtGui, QtPrintSupport, QtWidgets

import numpy as np
import pandas as pd
import seaborn as sns

class MainWindow(QtWidgets.QMainWindow):
    
    def __init__(self):        
        super(MainWindow, self).__init__()
        self.setObjectName("MainWindow")
        self.resize(300, 60)
        self.setWindowTitle("Testing PyInstaller")
        self.centralwidget = QtWidgets.QWidget(self)
        self.centralwidget.setObjectName("centralwidget")
        self.pushButtonExit = QtWidgets.QPushButton(self.centralwidget)
        self.pushButtonExit.setGeometry(QtCore.QRect(200, 10, 75, 23))
        self.pushButtonExit.setObjectName("pushButtonExit")
        self.pushButtonExit.setText("Exit")
        self.pushButtonExit.clicked.connect(self.close_main_window)
        self.setCentralWidget(self.centralwidget)    
            
    def close_main_window(self):               
        self.close()         
            
if __name__ == "__main__":  
    application = QtWidgets.QApplication(sys.argv)
    main_window = MainWindow()
    main_window.show()
    sys.exit(application.exec_())

exe file created without no errors

run the exe file and got the error:

(intel_project_example) C:\Users\ebonat\eclipse-workspace\qt_designer_test\src>C:\Users\ebonat\eclipse-workspace\qt_designer_test\src\dist\test_py_install\test_py_install.exe
Traceback (most recent call last):
  File "test_py_installer_for_windows.py", line 27, in <module>
    import numpy as np
  File "c:\snaps\appdata\local\continuum\anaconda3\envs\intel_project_example\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 621, in exec_module
    exec(bytecode, module.__dict__)
  File "site-packages\numpy\__init__.py", line 150, in <module>
  File "c:\snaps\appdata\local\continuum\anaconda3\envs\intel_project_example\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 621, in exec_module
    exec(bytecode, module.__dict__)
  File "site-packages\numpy\random\__init__.py", line 180, in <module>
  File "mtrand.pyx", line 1, in init numpy.random.mtrand
ModuleNotFoundError: No module named 'numpy.random.common'
[7212] Failed to execute script test_py_installer_for_windows

thanks for your help!

@ebonat
Copy link
Author

ebonat commented Aug 7, 2019

i have updated numpy from 1.17.0 to 1.16.4 and now everything works. why?

is pyinstaller need to be upgraded?

thank you for your help.

@htgoebel
Copy link
Member

htgoebel commented Aug 8, 2019

Looks like the numpy hook need an update.
We would appreciate if you'd submit a pull-request for this. See this section of the manual for more information about how to implement hooks.

@okzz
Copy link

okzz commented Aug 8, 2019

I experience the same issue and have tried every option I'm aware of, i.e. forcing import in the spec file, modifying setup.py, adding hook file, using --hidden-import flag, changing numpy version - but the error occurs persistently.

@ebonat
Copy link
Author

ebonat commented Aug 8, 2019

i think, i would like to see the final developed pyinstaller version with the list of the library version that works properly with that pyinstaller version. for example: developed pyinstaller version 4.0.0 works the following libraries and below versions: numpy 1.16.4, pandas 0.23.4, etc. this will allow me to get the right libraries version for development and final deployment - saving many hours of testing for everyone! or, let us know how to update any library pyinstaller hook properly - this could be a simple solution? let's wait for the pyinstaller team to take care about this issue. thanks all for your feedback!

@htgoebel
Copy link
Member

htgoebel commented Aug 8, 2019

list of the library version that works properly

See tests/rqeuirements-libraries.txt

let's wait for the pyinstaller team to take care about this issue

Since you are the OP and expect us to solve this, I'm closing this. We are not your service-crew.

@htgoebel htgoebel closed this as completed Aug 8, 2019
@htgoebel htgoebel added area:hooks Caused by or effecting some hook solution:won't fix Resolved: Maintainers will not fix this. labels Aug 8, 2019
@ebonat
Copy link
Author

ebonat commented Aug 8, 2019

thank you very much for your support.

@Levi-Lesches
Copy link

This was mentioned in Numpy issue #numpy/numpy#14163. Looks like it will be fixed in update 1.17.1. For now, a quick workaround is to include this at the top of your script:

import numpy.random.common
import numpy.random.bounded_integers
import numpy.random.entropy

@IvoryLu
Copy link

IvoryLu commented Oct 1, 2019

My Numpy version is 1.17.2 But I still received this error.
image

@amine-aboufirass
Copy link

amine-aboufirass commented Oct 10, 2019

@htgoebel

You're overreacting. This is an issue that many PyInstaller users are experiencing with a key python library: numpy.

Please get over your personal squabble with @ebonat and let us know what you in collaboration with the user community can do to fix this. Without users your library will not survive. This issue needs to be reopened.

Thanks for your feedback.

@ebonat
Copy link
Author

ebonat commented Oct 10, 2019

hi all,

i agreed with @awa5114. let's work together to fix this issue. for me, pyinstaller is one of
the best python deployment tools available today, i love it!

if time is needed for testing, i'll do it for sure. just let me know how can i help?

thank you very much for all your support.

@bjce
Copy link

bjce commented May 13, 2021

hello all

I currently have the same issue with numpy

MacOS 11.2.3
numpy 1.19.5
pyinstaller 4.3
Python 3.8.7

I tried to add the following on the top of the file.py to be compiled:

import numpy.random.common
import numpy.random.bounded_integers
import numpy.random.entropy

But it didn't help and I still get the the message:

ModuleNotFoundError: No module named 'numpy'

Do you have any idea what else could be done?

Many thanks in advance for your support and maintaining the package

@bwoodsend
Copy link
Member

@bjce That's not this issue. You're just muddling virtual environments. Check your code works with python your-code.py then invoke PyInstaller with python -m PyInstaller your-code.py.

@bjce
Copy link

bjce commented May 13, 2021

Many thanks @bwoodsend!! Out of interest: with the information I gave you how did you figure out that that was the problem??

@bwoodsend
Copy link
Member

Mixing up venvs is probably the 2nd most common issue reported here (the 1st being hidden imports).

@raulvictorrosa
Copy link

In my case the problem was with import numpy.core.multiarray then for me, I solved that by importing it in the main file in my case it was src/server.py.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 16, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area:hooks Caused by or effecting some hook solution:won't fix Resolved: Maintainers will not fix this.
Projects
None yet
Development

No branches or pull requests

9 participants