pyinstaller not working with several warnings and errors - python-3.x

I am trying to turn my script into .exe file. When I use Pyinstaller I get several warnings and errors and it does not work:
193691 WARNING: Unable to find package for requirement greenlet from package gevent. 193691 WARNING: Unable to find package for requirement zope.event from package gevent. 193691 WARNING: Unable to find package for requirement zope.interface from package gevent.
I installed gevent package but these warnings still appear
2)\anaconda3\lib\site-packages\numpy\__init__.py:138: 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
I installed mkl-service package but this message still appears
3)ImportError: DLL load failed while importing _multiarray_umath: The module is not found.
I am using Anaconda navigator and I dont have any additional virtual environment. I have numpy 1.19.2 and Python3.8.
Finally I get PyInstaller.exceptions.ImportErrorWhenRunningHook: Failed to import module __PyInstaller_hooks_0_numpy_core required by hook for module anaconda3\lib\site-packages\PyInstaller\hooks\hook-numpy.core.py. Please check whether module __PyInstaller_hooks_0_numpy_core actually exists and whether the hook is compatible with your version of \anaconda3\lib\site-packages\PyInstaller\hooks\hook-numpy.core.py:
I tried uninstalling anaconda and numpy and reinstalling it. I tried checking Path environment variable. all with no luck.

Related

Cupy DLL load failed

I am trying 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, importError: DLL load failed.
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:
when I tried pip install cupy-cuda112, cupy import is working but pytorch import is not working.
Error loading "C:\Users\CT1\miniconda3\envs\DentiumRIP\lib\site-packages\torch\lib\cublas64_11.dll" or one of its dependencies.
And, when I do conda install pytorch torchvision torchaudio cudatoolkit=11.2 -c pytorch -c conda-forge, the cupy import doesn't work.
please tell me how to fix it..
Failed to import CuPy.
If you installed CuPy via wheels (cupy-cudaXXX or cupy-rocm-X-X), make sure that the package matches with the version of CUDA or ROCm installed.
On Linux, you may need to set LD_LIBRARY_PATH environment variable depending on how you installed CUDA/ROCm.
On Windows, try setting CUDA_PATH environment variable.
Check the Installation Guide for details:
https://docs.cupy.dev/en/latest/install.html
Original error:
ImportError: DLL load failed: 지정된 프로시저를 찾을 수 없습니다.

Install pywin32 package in google colab or kaggle notebook environment

pywin32 package was required to install as part of requirements to set up the environment for pix2pix implementation codebase, pywin32 is used to enable the features of the Win32 API in python. I tried to set up an environment in google colab, and produced the following error message during pywin32 setup.
ERROR: Could not find a version that satisfies the requirement pywin32
(from versions: none) ERROR: No matching distribution found for
pywin32
Similar issue with the following message encountered while trying to implement in kaggle:
ERROR: Could not find a version that satisfies the requirement pywin32
ERROR: No matching distribution found for pywin32
The same issue encountered when I tried in my local python environment (Python 3.6.10) in my mac.
Also, I attempt to install pywin32 package from its source itself, using the latest tag build-300 as suggested for python 3.5+. But no luck, installation terminated with the dependency issue with winreg package not found, following message was shown.
ModuleNotFoundError: No module named 'winreg'
Likewise, tried with fake-winreg, but no luck at all. I checked the platform in google colab by print(sys.platform), it shows linux. Please advise if there is any workaround to install pywin32 package in colab and/or resolution solving any issue reported in the above steps. Thank you in advance.
Note:
Issue can be replicated by simply try pip install pywin32 in native python environment, and !pip install pywin32 in colab or kaggle environment.
Unfortunately you can't install it in linux python, pywin32 is a package of extension modules for accessing Windows C and COM APIs in Windows python:
Python extensions for Microsoft Windows Provides access to much of the Win32 API, the ability to create and use COM objects, and the Pythonwin environment.
Google Colab
Kaggle

Pythonnet missing AddReference method

On Win10 1709 x64 PC, installed Python 3.7.4 64-bit and pythonnet-2.4.0-cp37-cp37m-win_amd64.whl. Confirmed clr.pyd and Python.Runtime.dll exist in:
C:\Users\me\AppData\Local\Programs\Python\Python37\Lib\site-packages\
Placed My.Assembly.dll in:
C:\Users\me\AppData\Local\Programs\Python\Python37\DLLs\
This script fails:
import clr
clr.AddReference("My.Assembly")
with error:
AttributeError: module 'clr' has no attribute 'AddReference'
When I remove the 2nd line, import clr succeeds, so it is finding clr.pyd.
Here are my currently-installed packages:
astroid==2.0.4
bottle==0.12.13
certifi==2018.10.15
chardet==3.0.4
colorama==0.3.9
conan==1.9.1
deprecation==2.0.6
distro==1.1.0
fasteners==0.14.1
future==0.16.0
idna==2.7
isort==4.3.4
lazy-object-proxy==1.3.1
mccabe==0.6.1
monotonic==1.5
node-semver==0.2.0
packaging==18.0
patch==1.16
pluginbase==0.7
Pygments==2.2.0
PyJWT==1.6.4
pylint==2.1.1
pyparsing==2.3.0
pythonnet==2.4.0
PyYAML==3.13
requests==2.20.1
six==1.11.0
tqdm==4.28.1
urllib3==1.24.1
wrapt==1.10.11
There is possibly a naming conflict with the clr string styling package, which imports from Lib\site-packages\clr\style_builder.py and contains no AddReference() method.
The correct clr module source code via the pythonnet package looks like this.
Try pip install pythonnet in a fresh environment to be sure there is no package conflict, then retry:
import clr
clr.AddReference()
I had a script named clr.py in my scripts folder :( Deleted it and all is good now.

ClobberError when trying to install the nltk_data package using conda?

I am trying to install nltk_data package to my environment natlang using conda by giving the following command:
(natlang) C:\Users\asus>conda install -c conda-forge nltk_data
I receive the following errors:
Verifying transaction: failed
CondaVerificationError: The package for nltk_data located at
C:\Users\asus\Anaconda3\pkgs\nltk_data-2017.10.22-py_0
appears to be corrupted. The path
'lib/nltk_data/corpora/propbank/frames/con.xml'
specified in the package manifest cannot be found.
ClobberError: This transaction has incompatible packages due to a shared
path.
packages: conda-forge::nltk_data-2017.10.22-py_0, conda-forge::nltk_data-
2017.10.22-py_0
path: 'lib/nltk_data/corpora/nombank.1.0/readme'
ClobberError: This transaction has incompatible packages due to a shared
path.
packages: conda-forge::nltk_data-2017.10.22-py_0, conda-forge::nltk_data-
2017.10.22-py_0
path: 'lib/nltk_data/corpora/nombank.1.0/readme-dictionaries'
ClobberError: This transaction has incompatible packages due to a shared
path.
packages: conda-forge::nltk_data-2017.10.22-py_0, conda-forge::nltk_data-
2017.10.22-py_0
path: 'lib/nltk_data/corpora/nombank.1.0/readme-nombank-proposition-
structure'
I am working on Anaconda 3, python version 3.6.5, windows 10 enterprise.
Can someone please tell me why this error is occurring and how can I fix it.
Background: I originally wanted to use punkt in one of my programs using the code lines:
import nltk_data
nltk.download()
This would open the nltk downloader and after installing all the packages including punkt, on further running the program I would still encounter the following error:
LookupError:
Resource [93mpunkt[0m not found.
Please use the NLTK Downloader to obtain the resource:
[31m>>> import nltk
>>> nltk.download('punkt')
I tried rerunning the nltk.donwload() and nltk.download('punkt') a couple of times with no change. So then I decided to simply install the nltk_data package to my environment based on the assumption that if I install the package to the env itself, I won't have to use the nltk.download function to use punkt.
Summarizing, I have the following two questions:
If I install the nltk_data package to my evn, do I still need to use the nltk.download function in my code? If yes, how do I resolve the lookup error?
If installing to the evn is enough, then how do I resolve the clobber error?
(ps: I apologize if this sounds stupid, I am very new to machine learning and working with python in general.)
The nltk_data repository is a collection of zipfiles and xml meta data. Usually, it is not installation through packaging tools such as conda or pip.
But there is this utility from conda-forge that tries to install the nltk_data, https://github.com/conda-forge/nltk_data-feedstock
To use it, on the terminal/command prompt/console, first add the conda-forge channel:
conda config --add channels conda-forge
Then you shouldn't need the -c option, and just use:
conda install nltk_data
Please try the above and see whether that get rids of the ClobberError.
This error is requesting you to download a specific nltk dataset call punkt:
Please use the NLTK Downloader to obtain the resource:
>>> import nltk
>>> nltk.download('punkt')
Running nltk.download() without specifying which specific dataset you want to download will call up a tkinter GUI which normally wouldn't be possible if you are accessing your machine remotely without a GUI.
If you're unsure of which resource you need, I would suggest using the popular collection.
import nltk
nltk.download('popular')
Answering 2 que first- there have been similar issues all across windows machines. Its better to use the ntlk.download() function if you want to use punkt or a similar module.
1) The lookup error can easily be resolved. It was because of a typo. Instead of
import nltk_data
it should be
import nltk.data

psycopg2 import error due to failure to load libraries

I have tried many ways of installing psycopg2 after having installed PostgreSQL using the one-click installer, but anyway I try confronts me with the same import error in python: ImportError: dlopen(/Library/Python/2.5/site-packages/psycopg2/_psycopg.so, 2): Library not loaded: libpq.5.dylib
Referenced from: /Library/Python/2.5/site-packages/psycopg2/_psycopg.so
Reason: image not found
I am on Mac OS X 10.5.8. I am using Python 2.5. I installed PostgreSQL from the installer (I did not port it) and it installed in /Library). I added /Library/PostgreSQL/9.1/bin to the setup.cfg of the source psycopg2, as instructed in the INSTALL file and everywhere on the internet and then ran sudo python setup.py build and then sudo python setup.py install.
I also tried exporting /Library/PostgreSQL/9.1/bin to my path instead and running sudo pip install psycopg2. But the exact same problem occurred in all of these scenarii.
I would greatly appreciate some help with this.
Best
Marion
The problem is that at runtime the libpq.5.dylib file can't be found because it is not in one of the default locations searched by the dynamic (runtime) linker. Try to define the environment variable DYLD_LIBRARY_PATH before launching python. I am no MacOS X expert but something like:
export DYLD_LIBRARY_PATH=/Library/PostgreSQL/9.1/lib
will probably work.

Resources