So I'm trying to package a python script into an exe that can run on a Windows machine without needing a python install. I'm running WIn7 & my application uses pywin32 & the launcher is a file called console.py which takes in a couple of command line arguments and executes another script
I created a setup.py file upon which I ran python setup.py build, with the following setup file
from cx_Freeze import setup, Executable
setup(
name = "OneNote Email Notifications",
version = "0.1",
description = "An email notifier for OneNote",
executables = [Executable("console.py")]
)
That returned the following error,
Traceback (most recent call last):
File "C:\Python32\lib\site-packages\cx_Freeze\initscripts\Console3.py", line 2
7, in <module>
exec(code, m.__dict__)
File "console.py", line 1, in <module>
File "C:\Users\Varun\Desktop\My Dropbox\OnePy\OM\Notifications v0.2\notificati
ons.py", line 1, in <module>
import application
File "C:\Users\Varun\Desktop\My Dropbox\OnePy\OM\Notifications v0.2\applicatio
n.py", line 1, in <module>
import ApplicationServer
File "C:\Users\Varun\Desktop\My Dropbox\OnePy\OM\Notifications v0.2\Applicatio
nServer.py", line 5, in <module>
win32com.client.gencache.Rebuild()
File "C:\Python32\lib\site-packages\win32com\client\gencache.py", line 649, in
Rebuild
_SaveDicts()
File "C:\Python32\lib\site-packages\win32com\client\gencache.py", line 65, in
_SaveDicts
f = open(os.path.join(GetGeneratePath(), "dicts.dat"), "wb")
File "C:\Python32\lib\site-packages\win32com\client\gencache.py", line 141, in
GetGeneratePath
f = open(fname,"w")
IOError: [Errno 2] No such file or directory: 'C:\\Users\\Varun\\Desktop\\My Dro
pbox\\OnePy\\OM\\Notifications v0.2\\build\\exe.win-amd64-3.2\\library.zip\\win3
2com\\gen_py\\__init__.py'
so I figured perhaps there was an issue reading into the zipfile and decided to run build without creating library.zip. So I changed setup.py to
from cx_Freeze import setup, Executable
setup(
name = "OneNote Email Notifications",
version = "0.1",
description = "An email notifier for OneNote",
options = {"build_exe": {
"create_shared_zip": False,
"append_script_to_exe": True,
"include_in_shared_zip": False,
}
},
executables = [Executable("console.py")]
)
and now I get the following error message:
Traceback (most recent call last):
File "C:\Python32\lib\site-packages\cx_Freeze\initscripts\Console3.py", line 2
7, in <module>
exec(code, m.__dict__)
File "console.py", line 1, in <module>
File "C:\Users\Varun\Desktop\My Dropbox\OnePy\OM\Notifications v0.2\notificati
ons.py", line 1, in <module>
import application
File "C:\Users\Varun\Desktop\My Dropbox\OnePy\OM\Notifications v0.2\applicatio
n.py", line 1, in <module>
import ApplicationServer
File "C:\Users\Varun\Desktop\My Dropbox\OnePy\OM\Notifications v0.2\Applicatio
nServer.py", line 5, in <module>
win32com.client.gencache.Rebuild()
File "C:\Python32\lib\site-packages\win32com\client\gencache.py", line 649, in
Rebuild
_SaveDicts()
File "C:\Python32\lib\site-packages\win32com\client\gencache.py", line 65, in
_SaveDicts
f = open(os.path.join(GetGeneratePath(), "dicts.dat"), "wb")
File "C:\Python32\lib\site-packages\win32com\client\gencache.py", line 141, in
GetGeneratePath
f = open(fname,"w")
IOError: [Errno 2] No such file or directory: 'C:\\Users\\Varun\\Desktop\\My Dro
pbox\\OnePy\\OM\\Notifications v0.2\\build\\exe.win-amd64-3.2\\console.exe\\win3
2com\\gen_py\\__init__.py'
Try including the win32com.gen_py package.
You can always look in the created zip and see if the directory exists (or as you have done - don't zip until everything works well).
Change to the following
#....
executables = [Executable("console.py", packages=[''win32com.gen_py])]
#....
Related
ERROR IS :
Traceback (most recent call last):
File "P:\Prashant\Python\Attendance\lib\site-packages\pyzbar\zbar_library.py", line 58, in load
dependencies, libzbar = load_objects(Path(''))
File "P:\Prashant\Python\Attendance\lib\site-packages\pyzbar\zbar_library.py", line 50, in load_objects
deps = [
File "P:\Prashant\Python\Attendance\lib\site-packages\pyzbar\zbar_library.py", line 51, in <listcomp>
cdll.LoadLibrary(str(directory.joinpath(dep)))
File "C:\Users\kalep\AppData\Local\Programs\Python\Python39\lib\ctypes\__init__.py", line 452, in LoadLibrary
return self._dlltype(name)
File "C:\Users\kalep\AppData\Local\Programs\Python\Python39\lib\ctypes\__init__.py", line 374, in __init__
self._handle = _dlopen(self._name, mode)
FileNotFoundError: Could not find module 'libiconv.dll' (or one of its dependencies). Try using the full path with constructor syntax.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "P:\Prashant\CPP Project Planning\Rooturaj CPP PRoject\Attendance\attend.py", line 3, in <module>
from pyzbar .pyzbar import decode
File "P:\Prashant\Python\Attendance\lib\site-packages\pyzbar\pyzbar.py", line 7, in <module>
from .wrapper import (
File "P:\Prashant\Python\Attendance\lib\site-packages\pyzbar\wrapper.py", line 151, in <module>
zbar_version = zbar_function(
File "P:\Prashant\Python\Attendance\lib\site-packages\pyzbar\wrapper.py", line 148, in zbar_function
return prototype((fname, load_libzbar()))
File "P:\Prashant\Python\Attendance\lib\site-packages\pyzbar\wrapper.py", line 127, in load_libzbar
libzbar, dependencies = zbar_library.load()
File "P:\Prashant\Python\Attendance\lib\site-packages\pyzbar\zbar_library.py", line 60, in load
dependencies, libzbar = load_objects(Path(__file__).parent)
File "P:\Prashant\Python\Attendance\lib\site-packages\pyzbar\zbar_library.py", line 54, in load_objects
libzbar = cdll.LoadLibrary(str(directory.joinpath(fname)))
File "C:\Users\kalep\AppData\Local\Programs\Python\Python39\lib\ctypes\__init__.py", line 452, in LoadLibrary
return self._dlltype(name)
File "C:\Users\kalep\AppData\Local\Programs\Python\Python39\lib\ctypes\__init__.py", line 374, in __init__
self._handle = _dlopen(self._name, mode)
FileNotFoundError: Could not find module 'P:\Prashant\Python\Attendance\lib\site-packages\pyzbar\libzbar-64.dll' (or one of its dependencies). Try using the full path with constructor syntax.
I am creating project on attendance system using QR Code scanning and I use Python to create it.
I used all needed libraries in the program
like, cv2, numpy, pybase64, pyzbar.
But I am getting this above Error in the Pyzbar.
I got solution for this issue. I was facing similar issue just installed Visual C++ 64 bit version on my computer and restarted. Choose between vcredist_x86.exe or vcredist_x64.exe based on your machine.
https://www.microsoft.com/en-us/download/confirmation.aspx?id=40784. Hope this solves your issue as well.
I suspect this is a bit of a newb question, but I'm trying to run the following code using IDLE Shell 3.9.1:
from bitcoin.rpc import RawProxy
p = RawProxy()
info = p.getblockchaininfo()
print(info['blocks'])
And I am getting the following error:
Traceback (most recent call last):
File "C:\Users\Zack\Documents\Python\Scripts\crypto1.py", line 1, in <module>
from bitcoin.rpc import RawProxy
File "C:\Users\Zack\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\bitcoin\rpc.py", line 48, in <module>
from bitcoin.wallet import CBitcoinAddress, CBitcoinSecret
File "C:\Users\Zack\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\bitcoin\wallet.py", line 33, in <module>
import bitcoin.core.key
File "C:\Users\Zack\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\bitcoin\core\key.py", line 34, in <module>
_ssl = ctypes.cdll.LoadLibrary(ctypes.util.find_library('ssl') or 'libeay32')
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.496.0_x64__qbz5n2kfra8p0\lib\ctypes\__init__.py", line 452, in LoadLibrary
return self._dlltype(name)
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.496.0_x64__qbz5n2kfra8p0\lib\ctypes\__init__.py", line 374, in __init__
self._handle = _dlopen(self._name, mode)
FileNotFoundError: Could not find module 'libeay32' (or one of its dependencies). Try using the full path with constructor syntax.
Any thoughts on how to get beyond this? Thanks for your help!
I have created an exe file using py2exe, however it gives me an Attribute error and an import error on execution. I have used urllib2 and BeautifulSoup in my main script, which is abc.py
Here is my setup.py:
from distutils.core import setup
import py2exe
setup(console=['abc.py'])
options={"py2exe": {'includes': ["BeautifulSoup"]}}
I have added the 'includes' parameter after referring to another question on this website. It however doesn't work for me.
The output I get from abc.exe is
C:\Users\Dhruv Mullick\Desktop\dist>abc.exe Traceback (most recent
call last): File
"C:\Python27\lib\site-packages\py2exe\boot_common.py", line 92, in
import linecache File "linecache.pyc", line 9, in File "os.pyc", line 398, in File "UserDict.pyc", line 83,
in File "_abcoll.pyc", line 11, in File
"abc.pyc", line 3, in File "bs4__init__.pyc", line 30, in
File "bs4\builder__init__.pyc", line 1, in File
"collections.pyc", line 6, in AttributeError: 'module' object
has no attribute 'all' Traceback (most recent call last): File
"abc.py", line 3, in File "bs4__init__.pyc", line 26, in
File "os.pyc", line 398, in File "UserDict.pyc",
line 83, in File "_abcoll.pyc", line 11, in File
"abc.pyc", line 3, in ImportError: cannot import name
BeautifulSoup
C:\Users\Dhruv Mullick\Desktop\dist>
Your script 'abc.py' conflicts with the abc module in Python's standardlibrary.
Rename the script to something else (maybe abc_app.py), adapt the setup-script and rebuild.
You should also make sure to remove any 'abc.pyc' or 'abc.pyo' files which you may have. And remove the 'build' directory that py2exe creates...
I'd wish to compile my program wrote in Python 3.2 with Pygame 1.9.5. But I'm a beginner with cx_Freeze and I've no idea how to manage with the complex structure... I mean :
My folder is like that :
gamefolder:
lib:
Menu.py (lauch the program)
level.py
othermodules.py
...
data:
Level1.png
otherspictures.png
So I tried to compile but I always get an error when I lauch Main.exe, indeed I think pygame is not load and also the path are not really clear.
I hope there's a solution, and that with such a structure it will not be impossible because I'd rather not rewrote each path in the scripts ...
Further informations :
the setup.py script is in lib folder and looks like that:
from cx_Freeze import setup, Executable
setup(
name = "Resets",
version = "1.0",
description = "Jeu de plateforme - Projet ISN 2014",
executables = [Executable("Menu.py")]
)
And i get this error when I launch the Menu.exe :
Traceback (most recent call last):
File "C:\Python32\lib\site-packages\pygame\__init__.py", line 117, in <module>
try: import pygame.display
File "ExtensionLoader_pygame_display.py", line 22, in <module>
File "ExtensionLoader_pygame_display.py", line 14, in __bootstrap__
File "ExtensionLoader_pygame_surface.py", line 22, in <module>
File "ExtensionLoader_pygame_surface.py", line 14, in __bootstrap__
ImportError: No module named _view
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Python32\lib\site-packages\cx_Freeze\initscripts\Console3.py", line 2
7, in <module>
exec(code, m.__dict__)
File "Menu.py", line 8, in <module>
File "C:\Python32\lib\site-packages\pygame\__init__.py", line 118, in <module>
except (ImportError,IOError):display=MissingModule("display", geterror(), 1)
File "C:\Python32\lib\site-packages\pygame\__init__.py", line 61, in __init__
self.warn()
File "C:\Python32\lib\site-packages\pygame\__init__.py", line 85, in warn
warnings.warn(message, RuntimeWarning, level)
File "C:\Python\32-bit\3.2\lib\warnings.py", line 18, in showwarning
File "C:\Python\32-bit\3.2\lib\warnings.py", line 25, in formatwarning
File "C:\Python\32-bit\3.2\lib\linecache.py", line 15, in getline
File "C:\Python\32-bit\3.2\lib\linecache.py", line 41, in getlines
File "C:\Python\32-bit\3.2\lib\linecache.py", line 127, in updatecache
File "C:\Python\32-bit\3.2\lib\codecs.py", line 300, in decode
UnicodeDecodeError: 'utf-8' codec can't decode byte 0x90 in position 2: invalid
start byte
I already try with import pygame._view and import re but it doesn't work too...
Finally I succeeded, it was very simple !
I added import pygame._view in each script. And I copied the data folder into the folder (after being compiled).
I'm having trouble removing a resource file in a pyqt document, I'm also using monkeystudio IDE. I madea program with images and all linked to a resource file called "resources.qyc" and now I get the error
Traceback (most recent call last):
File "main.py", line 9, in <module>
from Login import Login
File "J:\Newone\Login.py", line 3, in <module>
import mainwindow
File "J:\Newone\mainwindow.py", line 2, in <module>
import Addcadet
File "J:\Newone\Addcadet.py", line 6, in <module>
( Ui_Addcadet, QDialog ) = uic.loadUiType( 'Addcadet.ui' )
File "C:\Python32\lib\site-packages\PyQt4\uic\__init__.py", line 203, in loadUiType
exec(code_string.getvalue(), ui_globals)
File "<string>", line 179, in <module>
ImportError: No module named resources_rc
You'll first have to compile the resource file using pyrcc4. You'll run something like this from command line:
pyrcc4 ResourceFile.qrc -o ui_ResourceFile.py