Error using Nuitka for Python App that uses Numpy, Pandas and Plotly - python-3.x

I've developed a PyQT5 app that also uses Numpy, Pandas and Plotly. To package it up I decided to use Nuitka however since the product is for the end users who won't be familiar with Python, I want to make sure the interpreter is packaged up along with the app as a single binary (similar to PyInstaller).
I'm running the following command however have been getting errors that I'm struggling to figure out how to fix:
$ python -m nuitka --standalone --show-progress --recurse-all --plugin-enable=numpy main.py
I'm using PyCharm and all the libraries are in the Virtual Environment in project directory. The version of Python I'm using is 3.9.
An executable binary is generated in Windows however upon running I receive the following error message:
C:\Users\user\PycharmProjects\PlotlyExample\main.dist>main
Traceback (most recent call last):
File "C:\Users\user\PYCHAR~1\PLOTLY~1\MAIN~1.DIS\numpy\core\__init__.py", line 22, in <module numpy.core>
File "C:\Users\user\PYCHAR~1\PLOTLY~1\MAIN~1.DIS\numpy\core\multiarray.py", line 12, in <module numpy.core.multiarray>
File "C:\Users\user\PYCHAR~1\PLOTLY~1\MAIN~1.DIS\numpy\core\overrides.py", line 7, in <module numpy.core.overrides>
ImportError: LoadLibraryExW 'C:\Users\user\PYCHAR~1\PLOTLY~1\MAIN~1.DIS\numpy\core\_multiarray_umath.pyd' failed: The specified module could not be found.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\user\PYCHAR~1\PLOTLY~1\MAIN~1.DIS\main.py", line 5, in <module>
File "C:\Users\user\PYCHAR~1\PLOTLY~1\MAIN~1.DIS\numpy\__init__.py", line 140, in <module numpy>
File "C:\Users\user\PYCHAR~1\PLOTLY~1\MAIN~1.DIS\numpy\core\__init__.py", line 48, in <module numpy.core>
ImportError:
IMPORTANT: PLEASE READ THIS FOR ADVICE ON HOW TO SOLVE THIS ISSUE!
Importing the numpy C-extensions failed. This error can happen for
many reasons, often due to issues with your setup or how NumPy was
installed.
We have compiled some common reasons and troubleshooting tips at:
https://numpy.org/devdocs/user/troubleshooting-importerror.html
Please note and check the following:
* The Python version is: Python3.9 from "C:\Users\user\PYCHAR~1\PLOTLY~1\MAIN~1.DIS\python.exe"
* The NumPy version is: "1.19.3"
and make sure that they are the versions you expect.
Please carefully study the documentation linked above for further help.
Original error was: LoadLibraryExW 'C:\Users\\user\PYCHAR~1\PLOTLY~1\MAIN~1.DIS\numpy\core\_multiarray_umath.pyd' failed: The specified module could not be found.
Sample Code:
https://pastebin.com/RjRYUk0C
Any ideas? Thanks!

Related

H5py Driver Issue on Qiskit Nature Drivers

While using the IBM Quantum experience, whenever I want to install any driver an error with the h5py appears.
Specifically, the error is
"Using default_file_mode other than 'r' is no longer supported. Pass
the mode to h5py.File() instead."
Does anyone have any solutions to it (not sure which version to revert back to). Thanks!!
You will need to add more details about your question. I could not replicate your error based on the information you provided. This is what I did:
First, I installed Qiskit Nature with this command pip install qiskit[nature].
Next, I entered the following Python commands:
>>> from qiskit_nature.drivers.second_quantization import HDF5Driver
>>> h5f = HDF5Driver()
>>> h5f
<qiskit_nature.drivers.second_quantization.hdf5d.hdf5driver.HDF5Driver object at 0x7fa28320a820>
>>> h5f.run()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/qiskit_nature/drivers/second_quantization/hdf5d/hdf5driver.py", line 63, in run
raise LookupError(f"HDF5 file not found: {hdf5_file}")
LookupError: HDF5 file not found: molecule.hdf5
There is no error when I imported the HDF5Driver module from the qiskit_nature package. An error occurs when I enter h5f.run(). This is expected, because I don't have a file named molecule.hdf5 (the default filename). If you have a different filename, modify commands above to use h5f = HDF5Driver("your_filename").
Tests run with Python 3.8.12 and qiskit_nature 0.3.0 running on Ubuntu Linux 5.11.0-1023-gcp.

CuPy import failing due to missing DLL file although it appears in my directories

I am attempting to use cuPy to speed up some background numpy operations in my python code but when attempting to import cupy I am told that the DLL load failed and the module could not be found, cupy_backends.cuda.libs import nvrtc. (Specific errors at end of post)
I've attempted almost everything the error message suggests. I check my version of cupy and cuda which are cupy-cuda111==8.4.0, I have Cuda 11.2 installed as well. I am running Windows 10 and Python 3.7.6 on Spyder 3. I have tried uninstalling cupy via pip uninstall in hopes of reinstalling correctly but it just hangs and never uninstalls the package.
It appears I have the file its looking for when I go search manually via my file explorer. (Imaged Below)
I am fairly inexperienced when it comes to handling things like this so any help would be greatly appreciated. The entire error message and trace is copied below:
import cupy as cp
Traceback (most recent call last):
File "C:\ProgramData\Anaconda3\lib\site-packages\cupy\__init__.py", line 20, in <module>
from cupy import core # NOQA
File "C:\ProgramData\Anaconda3\lib\site-packages\cupy\core\__init__.py", line 1, in <module>
from cupy.core import core # NOQA
File "cupy\core\core.pyx", line 1, in init cupy.core.core
File "C:\ProgramData\Anaconda3\lib\site-packages\cupy\cuda\__init__.py", line 5, in <module>
from cupy.cuda import compiler # NOQA
File "C:\ProgramData\Anaconda3\lib\site-packages\cupy\cuda\compiler.py", line 14, in <module>
from cupy_backends.cuda.libs import nvrtc
ImportError: DLL load failed: The specified module could not be found.
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "<ipython-input-1-e011b0e859cc>", line 1, in <module>
import cupy as cp
File "C:\ProgramData\Anaconda3\lib\site-packages\cupy\__init__.py", line 41, in <module>
raise ImportError(_msg) from e
ImportError: CuPy is not correctly installed.
If you are using wheel distribution (cupy-cudaXX), make sure that the version of CuPy you installed matches with the version of CUDA on your host.
Also, confirm that only one CuPy package is installed:
$ pip freeze
If you are building CuPy from source, please check your environment, uninstall CuPy and reinstall it with:
$ pip install cupy --no-cache-dir -vvvv
Check the Installation Guide for details:
https://docs.cupy.dev/en/latest/install.html
original error: DLL load failed: The specified module could not be found.

Installation of numpy through Anaconda

getting up to speed on Anaconda, I keep receiving an error message when I try to import 'numpy' into Python.
Here is what I have done so far:
Downloaded anaconda from anaconda.com (64-Bit Graphical
Installer (466 MB) with Python 3.7 for Windows);
Installed anaconda (under C:\Users\'Username'\Anaconda3 | Option 'Register Anaconda3 as my default Python 3.7')
Now I'm trying to import numpy into Python using idle.exe, which produces following error message:
Warning: os.path.expanduser("~") points to
h:\,
but the path does not exist.
Futhermore, after executing "'import 'numpy;" in IDLE I get the following error message.
Unfortunately none of the advice was helpful. Numpy seems to be properly installed.
Warning (from warnings module): File "C:\Users\'Username'\Anaconda3\lib\site-
packages\numpy\__init__.py", line 140
from . import _distributor_init
UserWarning: mkl-service package failed to import, therefore Intel(R) MKL
initialization ensuring its correct out-of-the box operation under condition
when Gnu OpenMP had already been loaded by Python process is not assured.
Please install mkl-service package, see http://github.com/IntelPython/mkl-
service
Traceback (most recent call last):
File "C:\Users\'Username'\Anaconda3\lib\site-packages\numpy\core\__init__.py",
line 24, in <module>
from . import multiarray
File "C:\Users\'Username'\Anaconda3\lib\site-packages\numpy\core\multiarray.py",
line 14, in <module>
from . import overrides
File "C:\Users\'Username'\Anaconda3\lib\site-packages\numpy\core\overrides.py",
line 7, in <module>
from numpy.core._multiarray_umath import (
ImportError: DLL load failed: The specified module could not be found.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\'Username'\Anaconda3\Scripts\myscripts\import_test.py", line 1,
in <module>
import numpy
File "C:\Users\'Username'\Anaconda3\lib\site-packages\numpy\__init__.py", line
142, in <module>
from . import core
File "C:\Users\'Username'\Anaconda3\lib\site-packages\numpy\core\__init__.py",
line 54, in <module>
raise ImportError(msg)
ImportError:
IMPORTANT: PLEASE READ THIS FOR ADVICE ON HOW TO SOLVE THIS ISSUE!
Importing the numpy c-extensions failed.
- Try uninstalling and reinstalling numpy.
- If you have already done that, then:
1. Check that you expected to use Python3.7 from
"C:\Users\'Username'\Anaconda3\python.exe",
and that you have no directories in your PATH or PYTHONPATH that can
interfere with the Python and numpy version "1.18.1" you're trying to use.
2. If (1) looks fine, you can open a new issue at
https://github.com/numpy/numpy/issues. Please include details on:
- how you installed Python
- how you installed numpy
- your operating system
- whether or not you have multiple versions of Python installed
- if you built from source, your compiler versions and ideally a build log
- If you're working with a numpy git repository, try `git clean -xdf`
(removes all files not under version control) and rebuild numpy.
Note: this error has many possible causes, so please don't comment on
an existing issue about this - open a new one instead.
Original error was: DLL load failed: The specified module could not be found.
Many thanks in advance for any help and suggestions.

Why am I getting a DLL error when importing numba in Python 3.8?

When I try (or another library tries) to import the 'numba' library I get the following error message: "DLL load failed while importing _typeconv: The specified module could not be found."
I have looked as deeply as I can in Google for similar occurrences and solutions. What I've found is only superficially similar and where solutions were even proposed they didn't work for me. At best I've come to the conclusion that I'm missing a particular DLL though I've no idea which one nor how to figure that out. Now I've got a Master's final project reliant on the usage of numba (indirectly, another third party library uses it) and I can't work around that.
I am using Python 3.8. It is the only Python installation on my Windows 10 machine (which is up-to-date as well). I am not using Anaconda nor am I willing to move to it at this point in time. I have installed numba on my system using "pip install numba" which gets the 0.49 version of numba.
After installing numba via pip, if I then start the Python CLI interface and attempt to import numba I get the following Traceback:
Python 3.8.0 (tags/v3.8.0:fa919fd, Oct 14 2019, 19:37:50) [MSC v.1916 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import numba
Traceback (most recent call last):
File "C:\Users\Luna\AppData\Local\Programs\Python\Python38\lib\site-packages\numba\core\typeconv\typeconv.py", line 4, in <module>
from numba.core.typeconv import _typeconv
ImportError: DLL load failed while importing _typeconv: The specified module could not be found.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\Luna\AppData\Local\Programs\Python\Python38\lib\site-packages\numba\__init__.py", line 20, in <module>
from numba.misc.special import (
File "C:\Users\Luna\AppData\Local\Programs\Python\Python38\lib\site-packages\numba\misc\special.py", line 3, in <module>
from numba.core.typing.typeof import typeof
File "C:\Users\Luna\AppData\Local\Programs\Python\Python38\lib\site-packages\numba\core\typing\__init__.py", line 1, in <module>
from .context import BaseContext, Context
File "C:\Users\Luna\AppData\Local\Programs\Python\Python38\lib\site-packages\numba\core\typing\context.py", line 11, in <module>
from numba.core.typeconv import Conversion, rules
File "C:\Users\Luna\AppData\Local\Programs\Python\Python38\lib\site-packages\numba\core\typeconv\rules.py", line 2, in <module>
from .typeconv import TypeManager, TypeCastingRules
File "C:\Users\Luna\AppData\Local\Programs\Python\Python38\lib\site-packages\numba\core\typeconv\typeconv.py", line 17, in <module>
raise ImportError(msg % (url, reportme, str(e), sys.executable))
ImportError: Numba could not be imported.
If you are seeing this message and are undertaking Numba development work, you may need to re-run:
python setup.py build_ext --inplace
(Also, please check the development set up guide http://numba.pydata.org/numba-doc/latest/developer/contributing.html.)
If you are not working on Numba development:
Please report the error message and traceback, along with a minimal reproducer
at: https://github.com/numba/numba/issues/new
If more help is needed please feel free to speak to the Numba core developers
directly at: https://gitter.im/numba/numba
Thanks in advance for your help in improving Numba!
The original error was: 'DLL load failed while importing _typeconv: The specified module could not be found.'
--------------------------------------------------------------------------------
If possible please include the following in your error report:
sys.executable: C:\Users\Luna\AppData\Local\Programs\Python\Python38\python.exe
Update
When rolling back to numba 0.48 this issue ends up disappearing.

Jupyter Notebook in Anaconda Not Loading

Whenever I try to open Jupyter Notebook from the Anaconda GUI (or conda terminal), I get the following error:
Traceback (most recent call last):
File "C:\Users\loops\AppData\Local\Continuum\anaconda3\lib\site-packages\notebook\services\sessions\sessionmanager.py", line 10, in
import sqlite3
File "C:\Users\loops\AppData\Local\Continuum\anaconda3\lib\sqlite3\__init__.py", line 23, in
from sqlite3.dbapi2 import *
File "C:\Users\loops\AppData\Local\Continuum\anaconda3\lib\sqlite3\dbapi2.py", line 27, in
from _sqlite3 import *
ImportError: DLL load failed: The specified procedure could not be found.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\loops\AppData\Local\Continuum\anaconda3\Scripts\jupyter-notebook-script.py", line 6, in
from notebook.notebookapp import main
File "C:\Users\loops\AppData\Local\Continuum\anaconda3\lib\site-packages\notebook\notebookapp.py", line 86, in
from .services.sessions.sessionmanager import SessionManager
File "C:\Users\loops\AppData\Local\Continuum\anaconda3\lib\site-packages\notebook\services\sessions\sessionmanager.py", line 13, in
from pysqlite2 import dbapi2 as sqlite3
ModuleNotFoundError: No module named 'pysqlite2'
I've gone so far as to uninstall Python, uninstall Anaconda, remove all python related path variables, and reinstall Anaconda with Python. This still has not worked. Is there any way to resolve this error? I've looked on many different sites but I haven't found much help.
EDIT: To add more context, it broke randomly one day and I don't have the slightest idea why. Anaconda had worked for a year or so prior. I checked both scripts that are referenced in the error prompt and they both exist in the directory.
I had the same problem.
The issue seems to arise from the missing of sqlite3.dll in the path ".\Anaconda\Dlls".(if using an env, you should put it under the env directory like ".\your env\DLLS") I solved it by simply copying that .dll file from others and put it under the path mentioned above.
You can download the sqlite3.dll from this link: sqlite3.dll

Resources