Packaging PySide with PyInstaller - pyside

I am trying to package a pyside + QML application within a single file.
When I run the executable I get this error
ImportError: could not import module 'PySide.QtNetwork'
Fatal Python error: can't initialize module QtDeclarative
Does someone have a clue ?
PS : I am on Windows

try to import module explicity:
import PySide.QtNetwork

Just want to say this solved an issue I had packaging a pySide application with pyImporter. I was getting this error:
Traceback (most recent call last): File "", line 93, in
File "c:\Users\Rizzo the
Rat\Desktop\PyInstaller-2.1\PyInstaller\loader\pyi_importers.py", line
409, in load_module
module = imp.load_module(fullname, fp, filename, self._c_ext_tuple) ImportError: could not import module 'PySide.QtXml'
until I added this line:
from PySide import QtXml

Related

ModuleNotFoundError: No module named 'pymatting_aot.aot'

I'm on Windows and I work with python 3.8.
If I execute a python script where libraries need to be compiled, I will get the following error:
Failed to import ahead-of-time-compiled modules.
This is expected on first import.
Compiling modules and trying again.
This might take a minute.
Traceback (most recent call last):
File "C:\Users\...\env\lib\site-packages\pymatting_aot\cc.py", line 36, in <module>
import pymatting_aot.aot
ModuleNotFoundError: No module named 'pymatting_aot.aot
I already installed pymatting with pip.
Does anybody now a solution to solve this error?

sklearn: ImportError: DLL load failed: The specified module could not be found

Ive updated my Python version from 3.5.4 to 3.6.6 (in Anaconda 3) and now the line
from sklearn.metrics.pairwise import cosine_similarity
causes the following error:
Traceback (most recent call last):
File "<ipython-input-3-743ac88bcf9a>", line 1, in <module>
from sklearn.metrics.pairwise import cosine_similarity
File "F:\Program Files\lib\site-packages\sklearn\__init__.py", line 64, in <module>
from .base import clone
File "F:\Program Files\lib\site-packages\sklearn\base.py", line 13, in <module>
from .utils.fixes import signature
File "F:\Program Files\lib\site-packages\sklearn\utils\__init__.py", line 13, in <module>
from .validation import (as_float_array,
File "F:\Program Files\lib\site-packages\sklearn\utils\validation.py", line 22, in <module>
from ..utils.fixes import signature
File "F:\Program Files\lib\site-packages\sklearn\utils\fixes.py", line 83, in <module>
from scipy.special import boxcox # noqa
File "F:\Program Files\lib\site-packages\scipy\special\__init__.py", line 640, in <module>
from ._ufuncs import *
ImportError: DLL load failed: The specified module could not be found.
Im on Windows 7, 64-bit; previously the line worked fine, and other packages (Pandas, Numpy etc) still work, so it doesn't appear to be a PATH issue as some have suggested.
Ive seen numerous similar questions but all solutions have so far failed. E.g.
roll the installation back to Python 3.5.4,
uninstall & re-install Pandas, Numpy, Scipy and Sklearn, also update MKL/MKL-RT.
The changes suggested in Error when trying to import sklearn modules : ImportError: DLL load failed: The specified module could not be found
were already implemented
Does anyone have any further suggestions (specific to Anaconda etc)?
I solved it, and (in my case) the problem was scipy, not sklearn.
What i did was uninstall scipy with conda: conda remove --force scipy, and then install it with pip: pip install scipy. That worked for me.

numpy imported successfully on command line but not on IDLE

I can import numpy successfully using my python version 2.7.11 on the command line :
but not in IDLE where I get the following error :
Traceback (most recent call last):
File "/Users/macbookpro/Desktop/Python learning/Mortgages/mortgage_plot.py", line 2, in <module>
import pylab
File "/Users/macbookpro/Library/Python/2.7/lib/python/site-packages/pylab.py", line 1, in <module>
from matplotlib.pylab import *
File "/Users/macbookpro/Library/Python/2.7/lib/python/site-packages/matplotlib/__init__.py", line 124, in <module>
from . import cbook
File "/Users/macbookpro/Library/Python/2.7/lib/python/site-packages/matplotlib/cbook/__init__.py", line 35, in <module>
import numpy as np
ImportError: No module named numpy
What could be the source of this problem ?
A possible candidate for this error can be that the numpy package is not present in the directories where your IDLE searches for the package.
However the package is available for your command line python package path. Try adding the package location to your IDLE's package search path. I think that should resolve this error.
You can add following lines at top to add package path ( for this program only ) to use numpy :
import sys
sys.path
sys.path.append('path/to/package/numpy')
import numpy
Download numpy package from http://www.lfd.uci.edu/~gohlke/pythonlibs/#numpy .
Or you can also work on anaconda

pyinstaller import error, no image found

I'm trying to make an application for a mac. When I use pyinstaller to make an exe on a windows machine, it works fine, but when I do it on a mac, the file complies, but then when executed I get the following errors.
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/PyInstaller/loader/pyi_importers.py", line 270, in load_module
exec(bytecode, module.__dict__)
File "/Library/Frameworks/Python.framework/Versions/2.7/bin/build/new_client/out00-PYZ.pyz/FileDialog", line 11, in <module>
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/PyInstaller/loader/pyi_importers.py", line 270, in load_module
exec(bytecode, module.__dict__)
File "/Library/Frameworks/Python.framework/Versions/2.7/bin/build/new_client/out00-PYZ.pyz/Tkinter", line 39, in <module>
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/PyInstaller/loader/pyi_importers.py", line 409, in load_module
module = imp.load_module(fullname, fp, filename, self._c_ext_tuple)
ImportError: dlopen(/var/folders/vb/vb9xryxdEz467ZADn0LL7U+++TI/-Tmp-/_MEIbvFCo2/_tkinter.so, 2): Library not loaded: #loader_path/Tcl
Referenced from: /var/folders/vb/vb9xryxdEz467ZADn0LL7U+++TI/-Tmp-/_MEIbvFCo2/_tkinter.so
Reason: image not found
It appears to be something wrong with Tkinter and TCL. Here are the modules that are loaded by the program.
import socket, thread, time, json, traceback, FileDialog
from functools import partial
from mtTkinter import *
I was using openpyxl and it required jdcal in the datetime.py module. None of the hidden imports or any of those pyinstaller work-arounds helped, running the exe would still say jdcal not found. The work-around that I used was to just copy the few functions from jdcal directly into the datetime.py in the openpyxl code. Then ran pyinstaller -F program.py
and it worked! Not the best answer, but when you are trying to get a project out the door for a client, it works.

Python No module named, even though the module does appear

Good day.
I've been using
pip install simplecv
to install the module simplecv.
I know the module was properly installed and when I'm printing list of the modules using
#!/usr/bin/env python2.7
import pip
installed_packages = pip.get_installed_distributions()
installed_packages_list = sorted(["%s==%s" % (i.key, i.version)
for i in installed_packages])
print(installed_packages_list)
I can see it in the list : 'simplecv==1.3'
But for some reason I can't use it.
I've tried to export the path using
1) export PYTHONPATH="/usr/local/lib/python2.7"
2) export PYTHONPATH="/usr/local/lib/python2.7/site-packages"
3) export PYTHONPATH="/usr/local/lib/python2.7/dist-packages"
But nothing works
Any ideas?
The package name isn't the same as the module name. The module is called SimpleCV, as shown in the documentation. So we have
>>> import simplecv
Traceback (most recent call last):
File "<ipython-input-2-064db77601b3>", line 1, in <module>
import simplecv
ImportError: No module named simplecv
but
>>> import SimpleCV
Traceback (most recent call last):
File "<ipython-input-3-d3da1d75bea1>", line 1, in <module>
import SimpleCV
File "/usr/local/lib/python2.7/dist-packages/SimpleCV/__init__.py", line 3, in <module>
from SimpleCV.base import *
File "/usr/local/lib/python2.7/dist-packages/SimpleCV/base.py", line 59, in <module>
raise ImportError("Cannot load OpenCV library which is required by SimpleCV")
ImportError: Cannot load OpenCV library which is required by SimpleCV
I didn't bother installing the dependencies, so this didn't work, but if I had, it would have. :-)

Resources