ImportError: No module named _tkinter_finder - python

I am packaging my application using pyinstaller. It created the binary file, but it is not working. When I load the application on terminal I see this error
[9854] LOADER: Running BC_GUI_Client.py
Traceback (most recent call last):
File "FALCON_BC_CLIENT/BC_GUI_Client.py", line 145, in <module>
File "PIL/ImageTk.py", line 127, in __init__
File "PIL/ImageTk.py", line 192, in paste
File "/usr/local/lib/python2.7/dist-packages/PyInstaller/loader/pyimod03_importers.py", line 687, in load_module
module = imp.load_module(fullname, fp, filename, ext_tuple)
ImportError: No module named _tkinter_finder
[9854] Failed to execute script BC_GUI_Client
I am using python 2.7 and installed pyinstaller 3.3
Anything wrong here?

I was able to resolve a simiar issue by running pyinstaller with the following option added in the command:
--hidden-import='PIL._tkinter_finder'
Your command should look like this:
pyinstaller module.py --hidden-import='PIL._tkinter_finder'

Related

ImportError: No module named _shim

I am using PyInstaller to generate an executable from a python script. This is what I did:
sudo python2 -m PyInstaller ptemplatized.spec
It builds successfully the .exe but when I execute it I get the following error:
[19878] LOADER: Running pyi_rth_mpldata.py
[19878] LOADER: Running pyi_rth_multiprocessing.py
[19878] LOADER: Running pyi_rth__tkinter.py
[19878] LOADER: Running pyi_rth_pkgres.py
[19878] LOADER: Running physiocap_templatized.py
Traceback (most recent call last):
File "/home/abderrahmen/Bureau/PC/pour/physiocap_templatized.py", line 38, in <module>
import geopandas
File "/tmp/pip-build-2qvLhV/pyinstaller/PyInstaller/loader/pyimod03_importers.py", line 395, in load_module
File "/usr/local/lib/python2.7/dist-packages/geopandas/__init__.py", line 5, in <module>
from geopandas.io.file import read_file
File "/tmp/pip-build-2qvLhV/pyinstaller/PyInstaller/loader/pyimod03_importers.py", line 395, in load_module
File "/usr/local/lib/python2.7/dist-packages/geopandas/io/file.py", line 4, in <module>
import fiona
File "/tmp/pip-build-2qvLhV/pyinstaller/PyInstaller/loader/pyimod03_importers.py", line 395, in load_module
File "/home/hadoop/.local/lib/python2.7/site-packages/fiona/__init__.py", line 83, in <module>
from fiona.collection import BytesCollection, Collection
File "/tmp/pip-build-2qvLhV/pyinstaller/PyInstaller/loader/pyimod03_importers.py", line 395, in load_module
File "/home/hadoop/.local/lib/python2.7/site-packages/fiona/collection.py", line 9, in <module>
from fiona.ogrext import Iterator, ItemsIterator, KeysIterator
File "/tmp/pip-build-2qvLhV/pyinstaller/PyInstaller/loader/pyimod03_importers.py", line 684, in load_module
File "fiona/ogrext.pyx", line 1, in init fiona.ogrext
ImportError: No module named _shim
[19878] Failed to execute script ptemplatized
I tried looking for the module but it seems to not exist. Thank you.
EDIT:
So I got this answer on another website:
Fiona has extension modules and some fairly complicated logic in its
setup script to manage them with respect to different versions of the
GDAL library. This is why python setup.py build (as reported in
another issue) won't work, you have to do python setup.py build_ext
build. I think you'll need to find a way for pyinstaller to run the
build_ext command defined in fiona's setup.py and then you'll be all
set.
Can anyone tell me how can that be done in my case?
EDIT2:
I countred this error by installing an ancient gdal version using a tuto. Now my Pyinstaller creates the .exe without errors bur when I execute it on another Machine I get the same error. Isn't the goal from using PyInstaller is to execute an .exe file without having to install all modules? Why am I having an import error if PyInstaller worked well and created a proper .exe? Thanks

Python ide thonny installation error in ubuntu

I am facing the below issue while installing thonny ide for python.
Traceback (most recent call last):
File "/home/shrivatsa/.local/lib/python3.5/site-packages/thonny/workbench.py", line 287, in _init_runner runner.start()
File "/home/shrivatsa/.local/lib/python3.5/site-packages/thonny/running.py", line 67, instart self.reset_backend()
File "/home/shrivatsa/.local/lib/python3.5/site-packages/thonny/running.py", line 427, in reset_backend self._proxy = backend_class(configuraration_option)
File "/home/shrivatsa/.local/lib/python3.5/site-packages/thonny/running.py", line 596, in __init__ self._start_new_process()
File "/home/shrivatsa/.local/lib/python3.5/site-packages/thonny/running.py", line 762, in _start_new_process my_env["JEDI_LOCATION"] = self_prepare_jedi()
File "/home/shrivatsa/.local/lib/python3.5/site-packages/thonny/running.py", line 703, in _prepare_jedi import jedi ImportError: No module named 'jedi'
The application launches but no run button and dedug button is active.
As the error message shows you are missing the module named "jedi".
Try to install it before installing the IDE:
pip install jedi
According to Thonny blog, this IDE uses Jedi (autocompletion/static analysis library). So make sure it also installed (via pip, for example).

Python external on Azure ImportError No Module Found

If i locally run my code with python main.py, then this error occurs locally. If i run it with python3 main.py, it works as expected. I suspect my azure app service is not running the correct version of python, however, it is set to python 3.4
StdErr:
2018-06-30 19:47:13.785205: Unhandled exception in wfastcgi.py: Traceback (most recent call last):
File "D:\Python34\Scripts\wfastcgi.py", line 711, in main
env, handler = read_wsgi_handler(response.physical_path)
File "D:\Python34\Scripts\wfastcgi.py", line 568, in read_wsgi_handler
return env, get_wsgi_handler(handler_name)
File "D:\Python34\Scripts\wfastcgi.py", line 541, in get_wsgi_handler
handler = handler()
File ".\ptvs_virtualenv_proxy.py", line 120, in get_venv_handler
handler = get_wsgi_handler(os.getenv('WSGI_ALT_VIRTUALENV_HANDLER'))
File ".\ptvs_virtualenv_proxy.py", line 89, in get_wsgi_handler
raise ValueError('"%s" could not be imported%s' % (handler_name, last_tb))
ValueError: "main.app" could not be imported: Traceback (most recent call last):
File ".\ptvs_virtualenv_proxy.py", line 73, in get_wsgi_handler
handler = __import__(module_name, fromlist=[name_list[0][0]])
File "D:\home\site\wwwroot\main.py", line 2, in <module>
from newspaper import Article
ImportError: No module named 'newspaper'
UPDATE
So I went to the debug console in kudo and i ran python
-m pip install --upgrade -r d:\home\site\wwwroot\requirements.txt.
Here is the error
ERROR: b"'xslt-config' is not recognized as an internal or external command,\r\noperable program or batch file.\r\n" ** make sure the development packages of libxml2 and libxslt are installed ** Using build configuration of libxslt
One of the requirements is Pillow which requires libxml2 and libxslt. I've tried using wheels however, I've had no success.
UPDATE II
I tried to install virtualenv since it does not exist and I receive a permissions error.
UPDATE III
I ran this command
D:\home\python364x64>python -m pip install newspaper3k
I test everything locally, and it works perfect. I push and receive this error below.
Error occurred while reading WSGI handler:
Traceback (most recent call last):
File "D:\home\python364x64\wfastcgi.py", line 791, in main
env, handler = read_wsgi_handler(response.physical_path)
File "D:\home\python364x64\wfastcgi.py", line 633, in read_wsgi_handler
handler = get_wsgi_handler(os.getenv("WSGI_HANDLER"))
File "D:\home\python364x64\wfastcgi.py", line 600, in get_wsgi_handler
handler = __import__(module_name, fromlist=[name_list[0][0]])
File ".\app.py", line 8, in <module>
from newspaper import Article
File "D:\home\python364x64\lib\site-packages\newspaper\__init__.py", line 10, in <module>
from .api import (build, build_article, fulltext, hot, languages,
File "D:\home\python364x64\lib\site-packages\newspaper\api.py", line 12, in <module>
import feedparser
File "D:\home\python364x64\lib\site-packages\feedparser.py", line 316
raise KeyError, "object doesn't have key 'category'"
^
SyntaxError: invalid syntax
StdOut:
StdErr:
Per my experience, we have no permission to modify D:\home environment.
So , It's better to use python extension. Please follow the steps in this case: Azure Flask Routes Not found and use command python -m pip install newspaper to install additional packages in python extension.
Please make sure the package you want to install must match with version of python extension. Otherwise, it will throw error as follows.
Hope it helps you.

Python: ImportError no module named mysql.connector

I just created an exe from python script and when I tried to run it, it did not show up.
Then, I tried to run it from cmd and I got ImportError below:
Traceback (most recent call last):
File "tkintertest2.py", line 17, in <module>
File "Lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line
389, in load_module
File "MySQL.py", line 1, in <module>
ImportError: No module named mysql.connector
Failed to execute script tkintertest2
How to solve this? I have installed mysql.connector using both pip install and conda install.
According to the pyinstaller docs here, pyinstaller is not finding the python module, so explicitly include it like so:
pyinstaller --hidden-import mysql.connector myscript.py

Pyinstaller failed to build wxpython app with error wx._xml missing

I tried to build my wxpython app with Pyinstaller, it built ok but when run, an exception occurred with message:
File "wx_gui.py", line 11, in <module>
import wx.xrc
File "c:\python34\lib\site-packages\PyInstaller\loader\pyimod03_importers.py",
line 389, in load_module
exec(bytecode, module.__dict__)
File "site-packages\wx\xrc.py", line 10, in <module>
File "c:\python34\lib\site-packages\PyInstaller\loader\pyimod03_importers.py",
line 573, in load_module
module = loader.load_module(fullname)
ImportError: No module named 'wx._xml'
Failed to execute script ir2_main
I checked in the site-packages folder and there was no wx._xml.pyd like there was wx._xrc.pyd. Could this be the reason and how can I fix it ?
As you seem to use Python 3.4 therefore you can only use wxPython Phoenix.
Looking into the last snapshot build wheel from end of October 2016 there is actually a _xml.pyd there, so maybe you have a bonkers wxPython installation?

Categories