xgboost error: not a valid Win32 application - python

I want to use XGBoost. When I try to execute code it always shows this error given below.
Exception has occurred: xgboost.core.XGBoostError
XGBoost Library (xgboost.dll) could not be loaded. Likely causes: * OpenMP
runtime is not installed (vcomp140.dll or libgomp-1.dll for Windows,
libgomp.so for UNIX-like OSes) * You are running 32-bit Python on a 64-bit
OS Error message(s): ['[WinError 193] %1 is not a valid Win32 application']
File "G:\study\research\gbm\<frozen importlib._bootstrap>", line 205,
in _call_with_frames_removed
File "G:\study\research\gbm\<frozen importlib._bootstrap_external>",
line 678, in exec_module
File "G:\study\research\gbm\<frozen importlib._bootstrap>", line 655,
in _load_unlocked
File "G:\study\research\gbm\<frozen importlib._bootstrap>", line 950,
in _find_and_load_unlocked
File "G:\study\research\gbm\<frozen importlib._bootstrap>", line 961,
in _find_and_load
File "G:\study\research\gbm\<frozen importlib._bootstrap>", line 205,
in _call_with_frames_removed
File "G:\study\research\gbm\<frozen importlib._bootstrap_external>",
line 678, in exec_module
File "G:\study\research\gbm\<frozen importlib._bootstrap>", line 655,
in _load_unlocked
File "G:\study\research\gbm\<frozen importlib._bootstrap>", line 950,
in _find_and_load_unlocked
File "G:\study\research\gbm\<frozen importlib._bootstrap>", line 961,
in _find_and_load
File "G:\Study\Research\GBM\gbm.py", line 4, in <module>
from xgboost import XGBClassifier
I install xgboost, downloaded the dll file and installed it.

For me even though everything was on 64-bit I still got this error.
Finally I found XGBoost requires Visual Studio 2017 C++ Redistributable installed in the windows machine..

Related

Error in geopandas module while running binary application of python script in linux

When I run python script it is working fine but when tried to run executable of same python script made using pyinstaller then getting module error. Specifically getting error while importing geopanda module. The error coming is mentioned below:
ERROR 1: PROJ: proj_create_from_database: Cannot find proj.db
PROJ: proj_create_from_database: Cannot find proj.db
Traceback (most recent call last):
File "ImageChecker.py", line 27, in <module>
File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
File "PyInstaller/loader/pyimod03_importers.py", line 495, in exec_module
File "geopandas/__init__.py", line 17, in <module>
File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
File "PyInstaller/loader/pyimod03_importers.py", line 495, in exec_module
File "geopandas/datasets/__init__.py", line 6, in <module>
StopIteration
[7062] Failed to execute script 'ImageChecker' due to unhandled exception!

The 'google-api-python-client' distribution was not found on running EXE compiled by pyinstaller

My application using google calendar API with the Google Python client library
from googleapiclient.discovery import build
for
events_result = service.events().list(calendarId='primary', timeMin=now,
maxResults=100, singleEvents=True,
orderBy='startTime').execute()
Create EXE using py installer
Versions -
72 INFO: PyInstaller: 4.1.dev0
72 INFO: Python: 3.9.0
74 INFO: Platform: Windows-10-10.0.18362-SP0
79 INFO: wrote C:\Users\PC\AppData\Local\Programs\Python\Python39\Scripts\main.spec
82 INFO: UPX is not available.
83 INFO: Extending PYTHONPATH with paths
Error
Traceback (most recent call last):
File "main.py", line 10, in <module>
File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
File "C:\Users\PC\AppData\Local\Programs\Python\Python39\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 493, in exec_module
exec(bytecode, module.__dict__)
File "googleapiclient\discovery.py", line 68, in <module>
File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
File "C:\Users\PC\AppData\Local\Programs\Python\Python39\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 493, in exec_module
exec(bytecode, module.__dict__)
File "googleapiclient\http.py", line 67, in <module>
File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
File "C:\Users\PC\AppData\Local\Programs\Python\Python39\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 493, in exec_module
exec(bytecode, module.__dict__)
File "googleapiclient\model.py", line 36, in <module>
File "pkg_resources\__init__.py", line 480, in get_distribution
File "pkg_resources\__init__.py", line 356, in get_provider
File "pkg_resources\__init__.py", line 899, in require
File "pkg_resources\__init__.py", line 785, in resolve
pkg_resources.DistributionNotFound: The 'google-api-python-client' distribution was not found and is required by the application
[15548] Failed to execute script main
line 10 -
from googleapiclient.discovery import build
The application working in pycharm and as python script in CMD
I used py installer in CMD
PyInstaller -F C:\Users\PC\PycharmProjects\.....
in script pycharm
import PyInstaller.__main__
PyInstaller.__main__.run([
'main.py',
'--onefile',
'--windowed'
])
Im following questions about this but did not find the answer
Thanks
The solution
copy the folder-- google_api_core-1.23.0-py3.8.egg-info-- to execute directory
rename folder name to ---google_api_python_client.egg-info--
On Windows, Copy Google directories from your Python Application install locations Python//Lib/site-packages directory to the dist/<dot_py_file> directory created by pyinstaller.

Missing dill was found using pyinstaller to compile executable file

I built a small program using sklearn, numpy and pandas, I tried to compile the file but it failed and have the following error message, it said there was a missing dll file in some location. I looked at this thread.
File "site-packages\PyInstaller\loader\pyiboot01_bootstrap.py", line 174, in __init__
File "ctypes\__init__.py", line 373, in __init__
FileNotFoundError: Could not find module 'C:\Users\Dennis\AppData\Local\Temp\_MEI101722\sklearn\.libs\vcomp140.dll' (or one of its dependencies). Try using the full path with constructor syntax.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "sklearn111.py", line 1, in <module>
File "<frozen importlib._bootstrap>", line 991, in _find_and_load
File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
File "c:\users\dennis\appdata\local\programs\python\python38-32\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 623, in exec_module
exec(bytecode, module.__dict__)
File "site-packages\sklearn\__init__.py", line 78, in <module>
File "<frozen importlib._bootstrap>", line 991, in _find_and_load
File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
File "c:\users\dennis\appdata\local\programs\python\python38-32\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 623, in exec_module
exec(bytecode, module.__dict__)
File "site-packages\sklearn\_distributor_init.py", line 18, in <module>
File "site-packages\PyInstaller\loader\pyiboot01_bootstrap.py", line 176, in __init__
__main__.PyInstallerImportError: Failed to load dynlib/dll 'C:\\Users\\Dennis\\AppData\\Local\\Temp\\_MEI101722\\sklearn\\.libs\\vcomp140.dll'. Most probably this dynlib/dll was not found when the application was frozen.
[6572] Failed to execute script gui_plus_model
So I put the dll it needs at the same folder with the .py file to be compiled, but the same error exist. The version of python is 3.8 and all modules needed have already been upgraded to the latest version.
pyinstaller -F --add-binary "vcomp140.dll;.dll" gui_plus_model.py

AttributeError: module 'opcode' has no attribute '__file__' for nuitka executable in a project including pandas and numpy

I'm trying to compile a python project including numpy and pandas with nuitka but no matter how I compile it, I have an error when launching the final executable.
For compilation I use the next command :
python -m nuitka --standalone --follow-imports --plugin-enable=numpy --include-plugin-directory=.venv/lib/python3.6/site-packages/pandas --include-plugin-directory=.venv/lib/python3.6/site-packages/numpy --show-progress --show-scons newick2phylipmatrix.py
But when I try to launch the executable generated by the compilation I get the following message :
Traceback (most recent call last):
File "/home/mindsound/sandbox/distMatrix/newick2phylipmatrix.dist/newick2phylipmatrix.py", line 6, in <module>
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 656, in _load_unlocked
File "<frozen importlib._bootstrap>", line 626, in _load_backward_compatible
File "/home/mindsound/sandbox/distMatrix/newick2phylipmatrix.dist/pandas/__init__.py", line 22, in <module pandas>
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 656, in _load_unlocked
File "<frozen importlib._bootstrap>", line 626, in _load_backward_compatible
File "/home/mindsound/sandbox/distMatrix/newick2phylipmatrix.dist/pandas/compat/numpy/__init__.py", line 3, in <module pandas.compat.numpy>
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 656, in _load_unlocked
File "<frozen importlib._bootstrap>", line 626, in _load_backward_compatible
File "/home/mindsound/sandbox/distMatrix/newick2phylipmatrix.dist/distutils/__init__.py", line 11, in <module>
AttributeError: module 'opcode' has no attribute '__file__'
Currently without changing anything to the code, I manage to create a standalone with pyinstaller but I can't do it with nuitka but if it's possible I would like to use it to benefit from compilation optimization.
Do you have any idea where this problem comes from and whether it can be solved ?
Well i finally got the solution for the same. The distutils created / copied by the virtualenv while creation is different from the one in the pythons original distribution. One of the teammember at Nuitka helped me discover the same and helped me reach the solution. Well the option i discovered was to pick up the distutils from the Pythons lib folder and replace the existing distutils folder in the virtualenv folder created and the go ahead - compile the same. I believe strongly that the issue will go away for you too as it have gone away for mine. Now will be looking to get in the proper solution for my complete project work.
Happy Compilation :)

Pycharm Run/Debug not working with tensorflow

I am on Windows 7 with python 3.5.4 and Pycharm Community Edition 2017.2
When I execute my python script in the cmd.exe it works fine. But when using the Run or Debug tools in Pycharm I get this error:
Traceback (most recent call last):
File "C:\Users\xy\my_project\env\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 18, in swig_import_helper
return importlib.import_module(mname)
File "C:\Users\xy\AppData\Local\Continuum\Anaconda3\lib\importlib\__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 986, in _gcd_import
File "<frozen importlib._bootstrap>", line 969, in _find_and_load
File "<frozen importlib._bootstrap>", line 958, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 666, in _load_unlocked
File "<frozen importlib._bootstrap>", line 577, in module_from_spec
File "<frozen importlib._bootstrap_external>", line 906, in create_module
File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed
ImportError: DLL load failed: Das angegebene Modul wurde nicht gefunden.
Now I am familiar with this specific error. Usually this occures if Microsoft Visual C++ Redistributable (or Visual Studio) is not installed. But this is not the case since I have installed the Microsoft Visual C++ 2015 Redistributable Update 3 (that's why the python script is working on the console).
My guess is, that I have to add some Path to Pycharm? But I do not know where or which one.
This is how I resolved the issue:
Open cmd.exe -> Create virtual env -> start Pycharm (pycharm.bat) from there

Categories