I am trying to build an exe file using py2exe. The script is to create some word clouds using pytagcloud.
The issue is that py2exe doesn't include the entire pytagcloud package because of which the exe doesn't work. What I mean by this is that in Lib\site-packages, pytagcloud contains two folders fonts and lang. However, after building the exe when I check the build, the fonts folder is missing. The exe itself gives this error:
Traceback (most recent call last):
File "wordcloud.py", line 6, in <module>
File "zipextimporter.pyc", line 82, in load_module
File "pytagcloud\__init__.pyc", line 25, in <module>
IOError: [Errno 2] No such file or directory: 'C:\\Users\\...\\dist\\wordcloud.exe\\pytagcloud\\fonts\\fonts.json'
I've been stuck at this for over 8 hours! I'm totally frustrated now! I would highly appreciate any help!
I am using Win 7, Python 2.7.3 and Pytagcloud 0.3.5
Related
Let me begin by saying I am very new to python so I will try to be as concise as possible, but please read my question with that thought in mind and have mercy on my ignorant soul.
I am working with an application, written in C++, that ships with Python version 3.4. The software allows users to write Python scripts and save them to a directory in order to control the program through these custom scripts. However, the Python library that ships with the software doesn't include matplotlib. Is it possible to use the pip installer to install matplotlib in this program's Python directory? I tried using --target with the pip installer, but that has not worked for me. If I cannot use pip, can anyone direct me to some documentation that might help me understand how to add packages to Python shipped within another program?
Furthermore, for future reference, is it possible to upgrade the version of Python within this program to Python 3.7 without access to the program's C++ source code?
Thank you for any input and help, and for not spitefully bashing my poorly posited question.
Edit:
Running path\to\python.exe -m site yielded the following:
C:\>"C:\path\python34\python.exe" -m site
sys.path = [
'C:\\',
'C:\\path\\python34\\python34.zip',
'C:\\path\\DLLs',
'C:\\path\\lib',
'C:\\path\\python34',
'C:\\path\\python34\\lib\\site-packages',
]
USER_BASE: 'C:\\Users\\user\\AppData\\Roaming\\Python' (exists)
USER_SITE: 'C:\\Users\\user\\AppData\\Roaming\\Python\\Python34\\site-packages' (doesn't exist)
ENABLE_USER_SITE: True
Running the command "path\python34\python" "path\pip-20.0.2-py2.py3-none-any.whl\pip" install -U -I pip yields the following output and subsequent error:
Traceback (most recent call last):
File "C:\path\python34\lib\runpy.py", line 170, in _run_module_as_main
"__main__", mod_spec)
File "C:\path\python34\lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "C:\path\pip-20.0.2-py2.py3-none-any.whl\pip\__main__.py", line 16, in <module>
File "C:\path\pip-20.0.2-py2.py3-none-any.whl\pip\_internal\cli\main.py", line 10, in <module>
File "C:\path\pip-20.0.2-py2.py3-none-any.whl\pip\_internal\cli\autocompletion.py", line 9, in <module>
File "C:\path\pip-20.0.2-py2.py3-none-any.whl\pip\_internal\cli\main_parser.py", line 7, in <module>
File "C:\path\pip-20.0.2-py2.py3-none-any.whl\pip\_internal\cli\cmdoptions.py", line 28, in <module>
File "C:\path\pip-20.0.2-py2.py3-none-any.whl\pip\_internal\models\target_python.py", line 4, in <module>
File "C:\path\pip-20.0.2-py2.py3-none-any.whl\pip\_internal\utils\misc.py", line 20, in <module>
File "C:\path\pip-20.0.2-py2.py3-none-any.whl\pip\_vendor\pkg_resources\__init__.py", line 35, in <module>
File "C:\path\python34\lib\plistlib.py", line 65, in <module>
from xml.parsers.expat import ParserCreate
File "C:\path\python34\lib\xml\parsers\expat.py", line 4, in <module>
from pyexpat import *
ImportError: DLL load failed: The specified procedure could not be found.
I am having trouble making a standalone application for Mac from a python Qt-based program, both when using cx_freeze and Py2App. (note that i did it successfully on Windows with cx_freeze).
Actually, the 'PyQt4' example provided with cx_freeze does not run properly on Mac. Is anyone able to "build" and run this example on a Mac?! I couldn't find any information on this seemingly basic problem on forums.
Indeed, let us build first:
~$ cd cx_Freeze-4.3.3/cx_Freeze/samples/PyQt4/
PyQt4$ ls
PyQt4app.py setup.py
PyQt4$ python setup.py build
running build
running build_exe
creating directory build/exe.macosx-10.5-x86_64-2.7
copying //anaconda/lib/python2.7/site-packages/cx_Freeze-4.3.3-py2.7-
macosx-10.5-x86_64.egg/cx_Freeze/bases/Console -> build/exe.macosx-10.5-x86_64-2.7/PyQt4app
TD bug fix: adding //anaconda/lib to relative path libpython2.7.dylib!
copying //anaconda/lib/libpython2.7.dylib -> build/exe.macosx-10.5-x86_64-2.7/libpython2.7.dylib
TD bug fix: adding //anaconda/lib to relative path libpython2.7.dylib!
writing zip file build/exe.macosx-10.5-x86_64-2.7/library.zip
…
copying //anaconda/lib/python2.7/lib-dynload/zlib.so -> build/exe.macosx-10.5-x86_64-2.7/zlib.so
PyQt4$
note the lines "TD bug fix…": in order to have the above run without 'file not found' error, i had to add a correction to function _GetDependentFiles in cx_freeze file freezer.py:
for i in range(len(dependentFiles)):
filei = dependentFiles[i]
if not os.path.isabs(filei):
print 'TD bug fix: adding ' + sys.prefix + '/lib to relative path ' + filei + '!'
dependentFiles[i] = os.path.join(sys.prefix,'lib',filei)
Now, when trying to run the created standalone program, I get:
PyQt4$ ls
PyQt4app.py build setup.py
PyQt4$ cd build/exe.macosx-10.5-x86_64-2.7/
exe.macosx-10.5-x86_64-2.7$ ls
PyQt4.QtCore.so _codecs_iso2022.so _struct.so libQtCore.dylib libz.1.dylib
PyQt4.QtGui.so _codecs_jp.so binascii.so libQtGui.4.dylib sip.so
PyQt4app _codecs_kr.so bz2.so libQtGui.dylib unicodedata.so
_codecs_cn.so _codecs_tw.so itertools.so libpython2.7.dylib zlib.so
_codecs_hk.so _multibytecodec.so libQtCore.4.dylib library.zip
exe.macosx-10.5-x86_64-2.7$ ./PyQt4app
Traceback (most recent call last):
File "//anaconda/lib/python2.7/site-packages/cx_Freeze-4.3.3-py2.7-macosx-10.5-x86_64.egg/cx_Freeze/initscripts/Console.py", line 27, in <module>
exec(code, m.__dict__)
File "PyQt4app.py", line 5, in <module>
File "ExtensionLoader_PyQt4_QtGui.py", line 22, in <module>
File "ExtensionLoader_PyQt4_QtGui.py", line 14, in __bootstrap__
ImportError: dlopen(/Users/thomasdeneux/cx_Freeze-4.3.3/cx_Freeze/samples/PyQt4/build/exe.macosx-10.5-x86_64-2.7/PyQt4.QtGui.so, 2): Library not loaded: #loader_path/../../../libQtGui.4.dylib
Referenced from: /Users/thomasdeneux/cx_Freeze-4.3.3/cx_Freeze/samples/PyQt4/build/exe.macosx-10.5-x86_64-2.7/PyQt4.QtGui.so
Reason: image not found
exe.macosx-10.5-x86_64-2.7$
It happens that some Qt libraries are not found because they are referenced with a complete relative path, while in the distribution all libraries were copied inside the same folder.
I have then moved to Py2App, hoping another package would not run into such problem. I don't show all the details now, only the most important lines when trying to build (this time i did not need to modify the code to get the building run) and run another simple Qt-based helloworld program:
test$ py2applet --make-setup helloworld.py
Wrote setup.py
test$ python setup.py py2app
running py2app
creating /Users/thomasdeneux/Documents/spyderworkspace/securebox/python/build/bdist.macosx-10.5-x86_64
...
Done!
test$ ./dist/helloworld.app/Contents/MacOS/helloworld
Traceback (most recent call last):
File "/Users/thomasdeneux/Documents/spyderworkspace/securebox/python/dist/helloworld .app/Contents/Resources/__boot__.py", line 351, in <module>
_run()
File "/Users/thomasdeneux/Documents/spyderworkspace/securebox/python/dist/helloworld .app/Contents/Resources/__boot__.py", line 336, in _run
exec(compile(source, path, 'exec'), globals(), globals())
File "/Users/thomasdeneux/Documents/spyderworkspace/securebox/python/dist/helloworld .app/Contents/Resources/helloworld.py", line 4, in <module>
from PyQt4.QtGui import *
File "PyQt4/QtGui.pyc", line 14, in <module>
File "PyQt4/QtGui.pyc", line 10, in __load
ImportError: dlopen(/Users/thomasdeneux/Documents/spyderworkspace/securebox/python/dist/helloworld.app/Contents/Resources/lib/python2.7/lib-dynload/PyQt4/QtGui.so, 2): Library not loaded: #loader_path/../../../libQtGui.4.dylib
Referenced from: /Users/thomasdeneux/Documents/spyderworkspace/securebox/python/dist/helloworld.app/Contents/Resources/lib/python2.7/lib-dynload/PyQt4/QtGui.so
Reason: image not found
2015-05-16 20:40:41.546 helloworld[983:707] helloworld Error
test$
Exactly the same kind of problem appears!
Thanks to anyone being able to help, whether by directly solving the issue or by advising another strategy for creating standalone programs for Mac from python/Qt projects.
I'm running a python script importing dataextract (from tableau api) csv,os, and datetime
when I run it I'm getting this error and I don't know where to start looking.The only line of code I am running is
import dataextract as tde
And I installed this library following tableau's tutorial
http://www.tableausoftware.com/learn/tutorials/on-demand/extract-api-introduction?signin=f850b055b106d24b93b365faad64838f
Traceback (most recent call last):
File "C:/Users/Ofri Harlev/Documents/Python/TableauFlatScript.py", line 1, in <module>
import dataextract as tde
File "C:\Python27\lib\site-packages\dataextract\__init__.py", line 15, in <module>
from Base import *
File "C:\Python27\lib\site-packages\dataextract\Base.py", line 17, in <module>
from . import StringUtils
File "C:\Python27\lib\site-packages\dataextract\StringUtils.py", line 17, in <module>
tablib = libs.load_lib
File "C:\Python27\lib\site-packages\dataextract\Libs.py", line 35, in load_lib
self.lib = ctypes.cdll.LoadLibrary(self.lib_path)
File "C:\Python27\lib\ctypes\__init__.py", line 443, in LoadLibrary
return self._dlltype(name)
File "C:\Python27\lib\ctypes\__init__.py", line 365, in __init__
self._handle = _dlopen(self._name, mode)
WindowsError: [Error 127] The specified procedure could not be found
After trying everything I found that the Tableau Extract Library only works on computers were Tableau is installed
I have faced the same problem while working with Python 2.7 and this is what I found:
-- Problem was coming because I have installed multiple versions of python (Python3.2, Python3.5 etc).
-- Because of multiple versions, at runtime there was multiple DLLs with same name (in all python versions library). So it was unable to figure out which one to load.
Solution:
I have uninstalled all python versions except one I needed (Python2.7) at time. Then run the program and now everything was working fine for me.
The app is working fine on my development win8 environment, but when it is packaged with py2exe and run on the production machine it throw the exception:
"The procedure entry point RtlIdnToAscii could not be located in the dynamic link library ntdll.dll"
The detail content of the log file is
Traceback (most recent call last):
File "DataviewerBackupRestorer.py", line 6, in <module>
File "RestorController.pyc", line 7, in <module>
File "psutil\__init__.pyc", line 136, in <module>
File "psutil\_psmswindows.pyc", line 14, in <module>
File "_psutil_mswindows.pyc", line 12, in <module>
File "_psutil_mswindows.pyc", line 10, in __load
ImportError: DLL load failed: The specified procedure could not be found.
It seems that a dll required by psutil is missing during the package process. I have tried to add the py2exe options with
py2exe_options = {"py2exe":{"includes":['decimal', '_mssql', 'uuid', 'psutil', '_psutil_mswindows']}}
But it is not working. Any ideas? Thanks in advance!
The solution is to remove System DLLs from the project directory. When I added psutil to my application py2exe added a lot of system DLLs to my project. It worked correctly on my and some other computers, but failed on another one. Removing from the project the .dll files that were available in C:\Windows\System32 solved the issue.
Finally in my case the solution was to add:
'dll_excludes': [ "IPHLPAPI.DLL", "NSI.dll", "WINNSI.DLL", "WTSAPI32.dll"]
into the py2exe options in setup.py file.
I am attempting to run a py2exe'd program (package.py) that includes pysvn. It is failing to run with the following error:
Traceback (most recent call last):
File "package.py", line 27, in <module>
File "zipextimporter.pyc", line 82, in load_module
File "pysvn\__init__.pyc", line 99, in <module>
File "zipextimporter.pyc", line 98, in load_module
ImportError: MemoryLoadLibrary failed loading pysvn\_pysvn_2_6.pyd
The script runs fine for others in the office, the difference being I'm on Windows 7 x64 with them on WinXP x86. I do have _pysvn_2_6.pyd in my pysvn directory.
Py2exe's "Problems to be Fixed" page has a similar error message with WxPython where it cannot find a needed system module, but I am not using WxPython and I have the dll they refer to anyway.
The py2exe page for "Working with Various Packages and Modules" doesn't refer to pysvn, and I can't find anyone else with similar problems.
I've checked the output of py2exe as outlined by this answer, but my computer seems to have all the binary files required in the correct locations.
EDIT:
I just tried to run other py2exe created programs on this same machine and they failed as well. It seems that the problem is with my machine (ie x64) rather than the specific program I was converting; I get a similar error with another program:
Traceback (most recent call last):
File "rundemo.py", line 13, in <module>
import win32api as w32
File "zipextimporter.pyc", line 98, in load_module
ImportError: MemoryLoadLibrary failed loading win32api.pyd
EDIT2:
I tried the py2exe programs generated from my 64 bit compy on a 32 bit machine, and they failed with the same error. I think I'm generating 32 bit exe's (py2exe docs say 64-bit support is experimental, and I haven't explicitly turned it on), but I'm not sure how to check to be sure.
Install PyWin32.
The py2exe project seems dead, so we rewrote our exes in C++. We can still build for Win7 x64 on our machines, but we couldn't get exe's wrote on Win7 to run on anything older.