ModuleNotFoundError for Pandas on standalone build
See original GitHub issueI’ve tried compiling a standalone application with a pandas==0.23.4
dependency, which gives a ModuleNotFoundError: No module named 'pandas._libs.tslibs.np_datetime'
exception on running.
This section of the pandas code does seem to also be cpython extensions / compiled *.so
’s. Also for reference, this is the line it raises on.
I’m unsure if nuitka should be auto descovering these kind of dependancies or not, I’ve seen similar things in pyinstaller. I did try adding variations of the argument --include-module=pandas._libs.tslibs.np_datetime
to the build command, was unsuccessful. Though looking in the
This might just be user error, though building this as a compiled module did not seem to have this problem, as I mentioned in #164.
Here’s the relevant code snippets:
0.6.0.3
Python: 3.7.0 (default, Sep 5 2018, 03:25:31)
Executable: /usr/local/bin/python
OS: Linux
Arch: x86_64
$ pip install nuitka==0.6.0.3 pandas==0.23.4`
# main.py
import pandas as pd
print(pd.Series([1, 2, 3]))
$ python -m nuitka main.py --standalone
$ main.dist/main
Traceback (most recent call last):
File ".../main.dist/pandas/__init__.py", line 26, in <module pandas>
File ".../main.dist/pandas/_libs/__init__.py", line 4, in <module pandas._libs>
File "pandas/_libs/tslibs/conversion.pxd", line 11, in init pandas._libs.tslib
File "pandas/_libs/tslibs/conversion.pyx", line 1, in init pandas._libs.tslibs.conversion
ModuleNotFoundError: No module named 'pandas._libs.tslibs.np_datetime'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File ".../main.dist/__main__.py", line 1, in <module>
File ".../main.dist/playground/__init__.py", line 1, in <module playground>
File ".../main.dist/playground/pandas_.py", line 1, in <module playground.pandas_>
File ".../main.dist/pandas/__init__.py", line 32, in <module pandas>
ImportError: C extension: No module named 'pandas._libs.tslibs.np_datetime' not built. If you want to import pandas from the source directory, you may need to run 'python setup.py build_ext --inplace --force' to build the C extensions first.
Issue Analytics
- State:
- Created 5 years ago
- Comments:12 (9 by maintainers)
Top GitHub Comments
This is still an issue with 0.6.5. Maybe it’s me being noob … I did the following:
Compile
Run the binary
It would be really great if this repository contained a few examples on how to compile non tivial python code with some popular libraries like opencv, PIL and numpy.
(The test suite seems awesome but it requires sometime to figure out …)
Update
I found out that if install nuitka in my virtualenv and run it again and run it in the following way:
Now the situation is a bit better
Hi @oz123 - I know you to be a PyMuPDF stargazer since a long time 😉
I recommend you use “hinted compilation” for standalone builds. As pointed out there, any required standard plugins are automatically included, and you in addition should end up with a smaller
dist
folder after a shorter compilation time. Let me repeat a few highlights here:get-hints.py
), which records all imports actually executed.python nuitka-hints.py yourscript.py
. As you see, this command line is very short. This is because the log file created in previous step is used to generated any additionally required parameters.