Bottom Page

Thread Rating:
  • 3 Vote(s) - 3 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 Error with Pyinstaller Modules
#1
Hey, I'm trying to create a bundled executable via PyInstaller for an assignment. Already tried multiple re-installations of Python but still PyInstaller creates Errors when building a Script without additional imports. I followed the PyInstaller Documentation, but can't figure out why these errors come up. Does anybody have an Idea?

#!/usr/bin/python3
print("Hello World")
input()
Error Log when build:

Error:
missing module named resource - imported by posix, C:\Users\sym\Desktop\check\pyinstaller_check.py missing module named posix - imported by os, C:\Users\sym\Desktop\check\pyinstaller_check.py missing module named _posixsubprocess - imported by subprocess, C:\Users\sym\Desktop\check\pyinstaller_check.py missing module named 'org.python' - imported by pickle, C:\Users\sym\Desktop\check\pyinstaller_check.py, xml.sax missing module named readline - imported by cmd, code, pdb, C:\Users\sym\Desktop\check\pyinstaller_check.py excluded module named _frozen_importlib - imported by importlib, importlib.abc, C:\Users\sym\Desktop\check\pyinstaller_check.py missing module named _frozen_importlib_external - imported by importlib._bootstrap, importlib, importlib.abc, C:\Users\sym\Desktop\check\pyinstaller_check.py missing module named _winreg - imported by platform, C:\Users\sym\Desktop\check\pyinstaller_check.py missing module named _scproxy - imported by urllib.request missing module named java - imported by platform, C:\Users\sym\Desktop\check\pyinstaller_check.py missing module named 'java.lang' - imported by platform, C:\Users\sym\Desktop\check\pyinstaller_check.py, xml.sax._exceptions missing module named vms_lib - imported by platform, C:\Users\sym\Desktop\check\pyinstaller_check.py missing module named termios - imported by tty, C:\Users\sym\Desktop\check\pyinstaller_check.py, getpass missing module named grp - imported by tarfile, shutil, C:\Users\sym\Desktop\check\pyinstaller_check.py missing module named pwd - imported by posixpath, tarfile, shutil, http.server, webbrowser, C:\Users\sym\Desktop\check\pyinstaller_check.py, netrc, getpass missing module named ce - imported by os, C:\Users\sym\Desktop\check\pyinstaller_check.py missing module named _dummy_threading - imported by dummy_threading, C:\Users\sym\Desktop\check\pyinstaller_check.py missing module named org - imported by copy, C:\Users\sym\Desktop\check\pyinstaller_check.py
*This is the Command Line I used: pyinstaller --clean --onedir "C:\Users\sym\Desktop\check\pyinstaller_check.py"
Quote
#2
Anyone? still stuck on this
atlass218 likes this post
Quote
#3
I am not familiar with Windows but what if you try ti run this with privileges?

And I see Python/pyinstaller can't find required modules. Try to add to environment variables PYTHONPATH='path_to_python_modules_directory'

Also, check out https://pythonhosted.org/PyInstaller/whe...wrong.html
I want to help more but I am not using Windows
"As they say in Mexico 'dosvidaniya'. That makes two vidaniyas."
https://freedns.afraid.org
Quote
#4
>>> s = "C:\Users\sym\Desktop\check\pyinstaller_check.py"
Traceback (most recent call last):
 File "C:\Python36\lib\code.py", line 63, in runsource
   code = self.compile(source, filename, symbol)
 File "C:\Python36\lib\codeop.py", line 168, in __call__
   return _maybe_compile(self.compiler, source, filename, symbol)
 File "C:\Python36\lib\codeop.py", line 99, in _maybe_compile
   raise err1
 File "C:\Python36\lib\codeop.py", line 87, in _maybe_compile
   code1 = compiler(source + "\n", filename, symbol)
 File "C:\Python36\lib\codeop.py", line 133, in __call__
   codeob = compile(source, filename, symbol, self.flags, 1)
 File "<interactive input>", line 1
SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: truncated \UXXXXXXXX escape
You can not use C:\U in python 3.
Turn all backslash the other way,as you should always do or double up \\.
>>> s = "C:/Users/sym/Desktop/check/pyinstaller_check.py"
>>> s
'C:/Users/sym/Desktop/check/pyinstaller_check.py'
Here a run with pyinstaller and the code you have postet.
I use virtual environment which now is build into Python 3.5 -->.
Virtual environment is great for not messing with OS installed Python versions.

Here the run from start to hello.exe.
I use cmder,but is't just the same in cmd.
wavic likes this post
Quote
#5
Hey, thank you very much for the reply. I followed your steps and was able to build the application in the venv and it is starting.
However the log  in C:\Python35\venv\build\hello\warnhello.txt still shows the following warnings.

Error:
missing module named resource - imported by posix, C:\Python35\venv\hello.py missing module named posix - imported by os, C:\Python35\venv\hello.py missing module named _posixsubprocess - imported by subprocess, C:\Python35\venv\hello.py missing module named 'org.python' - imported by pickle, C:\Python35\venv\hello.py, xml.sax missing module named ce - imported by os, C:\Python35\venv\hello.py missing module named readline - imported by cmd, code, pdb, C:\Python35\venv\hello.py excluded module named _frozen_importlib - imported by importlib, importlib.abc, C:\Python35\venv\hello.py missing module named _frozen_importlib_external - imported by importlib._bootstrap, importlib, importlib.abc, C:\Python35\venv\hello.py missing module named _winreg - imported by platform, C:\Python35\venv\hello.py missing module named _scproxy - imported by urllib.request missing module named java - imported by platform, C:\Python35\venv\hello.py missing module named 'java.lang' - imported by platform, C:\Python35\venv\hello.py, xml.sax._exceptions missing module named vms_lib - imported by platform, C:\Python35\venv\hello.py missing module named termios - imported by tty, C:\Python35\venv\hello.py, getpass missing module named grp - imported by tarfile, shutil, C:\Python35\venv\hello.py missing module named _dummy_threading - imported by dummy_threading, C:\Python35\venv\hello.py missing module named org - imported by copy, C:\Python35\venv\hello.py missing module named pwd - imported by posixpath, tarfile, shutil, http.server, webbrowser, C:\Python35\venv\hello.py, netrc, getpass
#!/usr/bin/python35
print("Hello")
input()
Command Line code to Build:
pyinstaller hello.py

I'm probably missing something obvious here, but I don't get how Errors like this "missing module named ce - imported by os, C:/Python35/venv/hello.py" come up in the log when building above python code. (as I literally import no modules there.)

When you are building the Code above in your Virtual Environment are there any error warnings in the .log in the build folder?
Quote
#6
(Jan-20-2017, 02:22 PM)sym Wrote: When you are building the Code above in your Virtual Environment are there any error warnings in the .log in the build folder?
I get the same error in log.
Look like it try to get import from a Linux version of Python.
The exe do work,so maybe just ignore the log.
Quote
#7
I see, thank you very much for the reply.

During the debugging I also looked into the hooks that are part of pyinstaller.
On Module imports like for example
import PyQt5.QtCore
the pyinstaller seems to find automatically the corresponding hooks during analysis and does not add anymore errors to the log.

However with the numpy module in the Python Code a lot of errors are added to the log. 
import numpy.core

There is an hook file for numpy in pyinstaller \Lib\site-packages\PyInstaller\hooks\hook-numpy.core.py for it but it does not seem to work.

Would you be able to confirm this? I wonder if it is something wrong on my end or if it's actually a bug in the current pyinstaller.
#!/usr/bin/python35
import numpy.core
a = numpy.array([1, 2])
a.fill(9)
print(a)
input()
Following Code adds all of this to the error log in the build directory:
Quote
#8
Test of numpy,it make a working exe for me.
There a stuff you have to know,now we work with virtual environment.
So numpy has to be install into virtual environment.
I use numpy for Gohlke,because we need wheel for not setting up a compiler.
So i activate environment and pip install wheel,i have placed wheel in scripts folder.
(pyinstaller_test) C:\Python35\pyinstaller_test\Scripts
λ pip install numpy-1.12.0+mkl-cp35-cp35m-win32.whl
Processing c:\python35\pyinstaller_test\scripts\numpy-1.12.0+mkl-cp35-cp35m-win32.whl
Installing collected packages: numpy
Successfully installed numpy-1.12.0+mkl
λ cd ..

# Make exe
(pyinstaller_test) C:\Python35\pyinstaller_test
λ pyinstaller numpy_test.py
Script i make exe of numpy_test.py
import numpy

a = numpy.array([1, 2])
a.fill(9)
print(a)
input()
(pyinstaller_test) C:\Python35\pyinstaller_test

λ pyinstaller numpy_test.py
A lot of install stuff..............
Now in dist folder numpy_test.exe(a working exe for me).
Quote
#9
Hey, thank you very much for the help. Using wheel helped to solve the numpy problem and the .exe is starting correctly.

There is now only one Module still causing an error for me. It is PySoundFile pip install pysoundfile, currently when I build an .exe with it included it crashes the app on start. I believe it might be the same behavior that happened with numpy before, however I have not found a proper wheel installation.

#!/usr/bin/python35
import numpy.core
import soundfile
print("Soundfile")
data, samplerate = soundfile.read("path to audio file")
print(samplerate)
print (data)
When launching the .exe via the Command Line I can see the following warnings:
Error:
Traceback (most recent call last):   File "lib\site-packages\soundfile.py", line 259, in <module>   File "lib\site-packages\cffi\api.py", line 139, in dlopen   File "lib\site-packages\cffi\api.py", line 769, in _make_ffi_library   File "lib\site-packages\cffi\api.py", line 757, in _load_backend_lib OSError: library not found: 'sndfile'
Quote
#10
Figured it out. The missing .dll needed to be specified as a seperate import in the pyinstaller .spec file.  Smile
Quote

Top Page

Forum Jump:


Users browsing this thread: 1 Guest(s)