0

I made a small program in Jupyter that uses the following libraries:

import pandas as pd
import datetime
 #import pvlib forecast models
from pvlib.forecast import RAP

I made it on jupyter and it runs fine, but I want to have a .exe that will run on a console that outputs a CSV, very simple. The issue is:

when I converted it to .py (it runs very well) I then use pyinstaller to create an .EXE that I can run on CMD and get the resulting CSV file but, I get the following errors:

File "solar_FX_py.py", line 15, in
File "", line 991, in _find_and_load
File "", line 975, in _find_and_load_unlocked
File "", line 671, in _load_unlocked
File "c:\users...\anaconda3\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 493, in exec_module
exec(bytecode, module.dict)
File "pvlib\forecast.py", line 5, in
from netCDF4 import num2date
File "", line 991, in _find_and_load
File "", line 975, in _find_and_load_unlocked
File "", line 671, in load_unlocked
File "c:\users...\anaconda3\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 493, in exec_module
exec(bytecode, module.dict)
File "netCDF4_init.py", line 3, in
File "include\membuf.pyx", line 16, in init netCDF4._netCDF4
AttributeError: type object 'netCDF4._netCDF4._MemBuf' has no attribute 'reduce_cython'

I have spent many days trying to figure out a fix for this but without success, I installed pvlib using the (optional) recommendation for forecast, and as I said, the .py file runs perfectly, but when I create the .exe it does not.

IS there a way to fix this? Or is there a better way to create a standalone application?

Thanks!!

Mark Mikofski
  • 19,398
  • 2
  • 57
  • 90
flmrck
  • 1
  • Do you have tried another netcdf libraray? – dl.meteo Oct 16 '20 at 10:26
  • Maybe PyInstaller is not bundling in the Cython compiled libraries required by netcdf4. I don't have experience with PyInstaller, but [this SO Q/A](https://stackoverflow.com/q/24525861/1020470) may hold some clues? Also your error looks like [this](https://pyinstaller.readthedocs.io/en/stable/feature-notes.html?highlight=cython#cython-support), therefore try passing the shared Cython compiled libraries to `pyinstaller` as [`--hidden-imports`](https://pyinstaller.readthedocs.io/en/stable/when-things-go-wrong.html?highlight=hidden#listing-hidden-imports). – Mark Mikofski Oct 27 '20 at 08:16
  • These `reduce_cython` errors should be mainly fixed by recompiling with a recent version of Cython. They're partly a consequence of circular imports (+ exceptions?) - i.e. you may have imported membuf from something that is imported by membuf and therefore membuf isn't full initialized. One of these imports may be in a try/catch block. – DavidW Oct 27 '20 at 08:59
  • Does this answer your question? [AttributeError with Scipy and Cython while converting Python to exe with cx\_Freeze](https://stackoverflow.com/questions/56134676/attributeerror-with-scipy-and-cython-while-converting-python-to-exe-with-cx-free) – ead Oct 27 '20 at 09:29
  • Thank you all for your help! This is my first approach to python and I am not very familiar with this stuff, nontheless I will try each of your suggestions and update here my progress. I read someone uses cx_freeze instead of pyinstaller, would using anything else than pyinstaller help? Any suggestion? THanks!! – flmrck Oct 28 '20 at 11:26

0 Answers0