Dependencies tracking on python application - python-3.4

I am trying to make a portable application from a python app I developped on Windows 7 - 32 bits using python3.4. My first idea was to use py2exe combined with a ThinApp equivalent, but as I use rasterio which is not a pure python library, py2exe does not manage to find some DLLs.
If I try to run the generated executable I get this error :
File Traceback (most recent call last):
File "viewer.py", line 3, in <module>
import MainWindow as GUI
File "C:\Users\IEUser\Documents\viewer-dev\viewer\MainWindow.py", line 2, in <module>
import ImageWindow
File "C:\Users\IEUser\Documents\viewer-dev\viewer\ImageWindow.py", line 1, in <module>
import Resampler
File "C:\Users\IEUser\Documents\viewer-dev\viewer\Resampler.py", line 1, in <module>
import rasterio
File "C:\Python34\lib\site-packages\rasterio\__init__.py", line 31, in <module>
from rasterio._base import gdal_version
File "<loader>", line 10, in <module>
File "<loader>", line 8, in __load
ImportError: (DLL load failed: The specified module could not be found.) 'C:\\Users\\IEUser\\Documents\\viewer-dev\\dist\\rasterio._base.pyd'
I read that I had to add these DLLs manually in the dist directory, but I wonder how could I get a list of the required DLLs ?

You can use the Dependency Walker on your py2exe to see all the missing dependencies.
Check the executable and all the linked libraries(PYD & DLL files)

Related

Getting following error while runnin juptyer notebook from ananconda prompt

Please let me know the solution to fix it as didn't find much on google.
Faced this error while trying to start jupyter notebook from anaconda.
But can open it from cmd.
Environment variables of anaconda are properly configured.
Traceback (most recent call last):
File "C:\Users\Ankit Chawrai\anaconda3\Scripts\jupyter-notebook-script.py", line 6, in <module>
from notebook.notebookapp import main
File "C:\Users\Ankit Chawrai\anaconda3\lib\site-packages\notebook\notebookapp.py", line 51, in <module>
from zmq.eventloop import ioloop
File "C:\Users\Ankit Chawrai\anaconda3\lib\site-packages\zmq\__init__.py", line 50, in <module>
from zmq import backend
File "C:\Users\Ankit Chawrai\anaconda3\lib\site-packages\zmq\backend\__init__.py", line 40, in <module>
reraise(*exc_info)
File "C:\Users\Ankit Chawrai\anaconda3\lib\site-packages\zmq\utils\sixcerpt.py", line 34, in reraise
raise value
File "C:\Users\Ankit Chawrai\anaconda3\lib\site-packages\zmq\backend\__init__.py", line 27, in <module>
_ns = select_backend(first)
File "C:\Users\Ankit Chawrai\anaconda3\lib\site-packages\zmq\backend\select.py", line 28, in select_backend
mod = __import__(name, fromlist=public_api)
File "C:\Users\Ankit Chawrai\anaconda3\lib\site-packages\zmq\backend\cython\__init__.py", line 6, in <module>
from . import (constants, error, message, context,
ImportError: DLL load failed while importing error: The specified module could not be found.```
I always launch Jupyter Notebooks from either from the Windows menu or the Anaconda Navigator. Almost always from the Windows Start Menu.
When I installed Anaconda a shortcut was created within the Start Menu, and when clicked it launches a cmd window, runs some scripts and then opens the Jupyter Explorer page within my default browser.

I get error "No module named 'pyproj._datadir'" after I made .py to .exe with pyinstaller [duplicate]

This question already has answers here:
Issues with pyinstaller and pyproj
(3 answers)
Closed 2 years ago.
My code works well when it's .py
but when I make .exe file with pyinstaller, it shows ModuleNotFoundError.
I write this when I made .exe
pyinstaller -F MyCode.py
How can I solve this problem?
I've read
Issues with pyinstaller and pyproj
and I was going to try to make and located hook-pyproj.py at "hooks" folder in Pyinstaller. but hook-pyproj.py was already there with the same code.
After that, I installed "basemap" and tried to use pyproj from it. However it shows me the same error.
This is the error it showed me when I execute the .exe file.
(I covered some information with *****)
Traceback (most recent call last):
File "collect\MyCode.py", line 8, in <module>
File "c:\users\*****\appdata\local\programs\python\python36-32\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 627, in exec_module
exec(bytecode, module.__dict__)
File "site-packages\mpl_toolkits\basemap\__init__.py", line 41, in <module>
File "c:\users\*****\appdata\local\programs\python\python36-32\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 627, in exec_module
exec(bytecode, module.__dict__)
File "site-packages\pyproj\__init__.py", line 62, in <module>
File "c:\users\*****\appdata\local\programs\python\python36-32\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 627, in exec_module
exec(bytecode, module.__dict__)
File "site-packages\pyproj\crs.py", line 26, in <module>
File "pyproj\_crs.pyx", line 1, in init pyproj._crs
ModuleNotFoundError: No module named 'pyproj._datadir'
[25936] Failed to execute script MyCode
This is my code.
from mpl_toolkits.basemap import pyproj as pyproj
I tried this at first.
import pyproj
but I get same " ModuleNotFoundError: No module named 'pyproj._datadir' " error.
It's a bit odd and I don't exactly understand why but I found a quick dirty fix.
You can add this import
from pyproj import _datadir, datadir
to your existing one.
I noticed this pyproj import dll error error occurred on some Windows machines and not others.
Turned out to be a dependency on Visual C Runtime 2015+
https://support.microsoft.com/en-au/help/2977003/the-latest-supported-visual-c-downloads

Problem when importing distributed on Ubuntu 18.04

I am trying to import distributed version 1.22.0 installed with pip3.
However, I get this error :
>>> import distributed
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.6/dist-packages/distributed/__init__.py", line 5, in <module>
from .core import connect, rpc
File "/usr/local/lib/python3.6/dist-packages/distributed/core.py", line 25, in <module>
from .system_monitor import SystemMonitor
File "/usr/local/lib/python3.6/dist-packages/distributed/system_monitor.py", line 4, in <module>
import psutil
File "/home/users/ej/.local/lib/python3.6/site-packages/psutil/__init__.py", line 100, in <module>
from . import _pslinux as _psplatform
File "/home/users/ej/.local/lib/python3.6/site-packages/psutil/_pslinux.py", line 26, in <module>
from . import _psutil_linux as cext
ImportError: /home/users/ej/.local/lib/python3.6/site-packages/psutil/_psutil_linux.cpython-36m-x86_64-linux-gnu.so: failed to map segment from shared object
>>>
I have dask version 0.18.1 installed with pip3.
I work on Ubuntu 18.04 with python3.
I tried reinstall and install but no solution.
Could you help me please ?
Thanks in advance.

No module named 'MBI' in CADRE plug-in

When I try to run CADRE plug-in it fails when trying to import 'MBI' module in 'CADRE.power' discipline:
Traceback (most recent call last):
File "C:\Users\Laurynas\CADRE\src\mppt.py", line 9, in <module>
from CADRE.power import Power_SolarPower, Power_CellVoltage
File "C:\Users\Laurynas\CADRE\src\CADRE\power.py", line 10, in <module>
from MBI import MBI
ModuleNotFoundError: No module named 'MBI'
Is this some kind of legacy python or OpenMDAO module? I was not able to find it in the web.
Yeah, MBI is a separate package, but you can find it here:
https://github.com/OpenMDAO/MBI

ImportError: No module named cryptography.hazmat.backends - anaconda on windows

I am using the Anaconda environment for python.
I have installed the paramiko (v. 2.0.2) and cryptography (v 1.5) modules using the Anaconda Navigator..
When I try to execute this import statement:
import netmiko
I get an error message "ImportError: No module named cryptography.hazmat.backends"
The total output in the cmd window is:
>>> import netmiko
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "build\bdist.win-amd64\egg\netmiko\__init__.py", line 1, in <module>
File "build\bdist.win-amd64\egg\netmiko\ssh_dispatcher.py", line 3, in <module>
File "build\bdist.win-amd64\egg\netmiko\cisco\__init__.py", line 1, in <module>
File "build\bdist.win-amd64\egg\netmiko\cisco\cisco_ios_ssh.py", line 1, in <module>
File "build\bdist.win-amd64\egg\netmiko\ssh_connection.py", line 3, in <module>
File "build\bdist.win-amd64\egg\netmiko\base_connection.py", line 13, in <module>
File "build\bdist.win-amd64\egg\paramiko\__init__.py", line 30, in <module>
File "build\bdist.win-amd64\egg\paramiko\transport.py", line 32, in <module>
ImportError: No module named cryptography.hazmat.backends
Does anyone know how to fix this?
Any help is appreciated.
I guess the right order for the commands would be:
#apt-get update
#apt-get install python-dev
#apt-get install libffi-dev
#pip install cryptography
It solved the issue in my case
You're probably running into a problem because you don't have libffi-dev installed. Installing "python-dev" and "libffi-dev" at the OS layer may help.

Resources