I have this pyopengl application and I'm trying to freeze it with bbfreeze. Unfortunately when I run the frozen app it errors with this:
Traceback (most recent call last):
File "<string>", line 6, in <module>
File "__main__.py", line 128, in <module>
File "__main__client__.py", line 11, in <module>
File "ui.py", line 15, in <module>
File "OpenGL/GLUT/__init__.py", line 2, in <module>
File "OpenGL/raw/GLUT/__init__.py", line 6, in <module>
File "OpenGL/raw/GLUT/constants.py", line 7, in <module>
File "OpenGL/platform/__init__.py", line 36, in <module>
File "OpenGL/platform/__init__.py", line 27, in _load
File "OpenGL/plugins.py", line 14, in load
File "OpenGL/plugins.py", line 28, in importByName
ImportError: No module named glx
Here's the requisite version information:
Python 2.6.6 (r266:84292, Sep 15 2010, 15:52:39)
[GCC 4.4.5] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import OpenGL
>>> OpenGL.__version__
'3.0.1b2'
>>> import bbfreeze
>>> bbfreeze.version
(0, 97, 3)
I'm trying to run it on the same machine I'm freezing it on, and the unfrozen app runs fine on that machine.
Has anyone managed to make this work? or perhaps provide some debugging guidance?
Try explicitly adding "OpenGL.platform.glx" to the list of included modules in the freeze. I think the bbfreeze option "includes" is what you want.
Update: take a look at the way PyInstaller does it: http://www.pyinstaller.org/browser/trunk/PyInstaller/hooks/hook-OpenGL.py
You will probably need to add all of these modules to your list of includes.
I am also facing the same challenge until I read the documention, which states that:
bbfreeze has been tested with python 2.4, 2.5 and 2.6. bbfreeze will not work with python versions prior to 2.3 as it uses the zipimport feature introduced with python 2.3.
So i think the best to do is to use the versions of python mentioned! Hope this helps!
Related
I am new to Python so I could perhaps learn the basics first... I'm a musician and keen to learn how to use Python with music.
I installed Python 3.8 x64 for Windows 10. I then used pip to install music21.
Opened the Python Shell, typed import music21 and got this:
Python 3.8.0 (tags/v3.8.0:fa919fd, Oct 14 2019, 19:37:50) [MSC v.1916 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license()" for more information.
>>> import music21
Traceback (most recent call last):
File "<pyshell#0>", line 1, in <module>
import music21
File "D:\Python\lib\site-packages\music21\__init__.py", line 170, in <module>
from music21 import base
File "D:\Python\lib\site-packages\music21\base.py", line 94, in <module>
from music21 import common
File "D:\Python\lib\site-packages\music21\common\__init__.py", line 39, in <module>
from music21.common.parallel import *
File "D:\Python\lib\site-packages\music21\common\parallel.py", line 19, in <module>
from music21.ext.joblib import Parallel, delayed # #UnresolvedImport # type: ignore
File "D:\Python\lib\site-packages\music21\ext\joblib\__init__.py", line 119, in <module>
from .parallel import Parallel
File "D:\Python\lib\site-packages\music21\ext\joblib\parallel.py", line 32, in <module>
from .externals.cloudpickle import dumps, loads
File "D:\Python\lib\site-packages\music21\ext\joblib\externals\cloudpickle\__init__.py", line 3, in <module>
from .cloudpickle import *
File "D:\Python\lib\site-packages\music21\ext\joblib\externals\cloudpickle\cloudpickle.py", line 167, in <module>
_cell_set_template_code = _make_cell_set_template_code()
File "D:\Python\lib\site-packages\music21\ext\joblib\externals\cloudpickle\cloudpickle.py", line 148, in _make_cell_set_template_code
return types.CodeType(
TypeError: an integer is required (got type bytes)
I have found example code to run with music21 but I can't use it if I get errors.
Hope someone can help. Apologies if I'm being a complete n00b. Did look at other questions but didn't find or didn't understand the answers.
So from your output, the main piece that seems most useful is the TypeError: an integer is required (got type bytes) in the _make_cell_set_template_code function in the D:\Python\lib\site-packages\music21\ext\joblib\externals\cloudpickle\cloudpickle.py file. This issue could be an issue with music21 not being compatible with Python 3.8. I'm reading the documentation from https://web.mit.edu/music21/ and it says v.5 support Python 3.4-3.6, so I would try to get on one of those versions and restart the process you did to get to the step above. Hope this helps!
music21 v5 does not support Python 3.8 -- choose 3.7 or download the latest Git from github.
EDIT: v5.7.2 now supports 3.8
When using python through the commandline, I am able to import modules fine. However, when I build a python script in SublimeText3, some modules don't import. I generally receive the following error:
ImportError: DLL load failed: The specified module could not be found.
The problem looks to involve modules with dependencies on modules with a "_" prefix (_sqlite3, _ssl). For example:
File "C:\ProgramData\anaconda3\Lib\sqlite3\__init__.py", line 23, in <module>
from sqlite3.dbapi2 import *
File "C:\ProgramData\anaconda3\Lib\sqlite3\dbapi2.py", line 27, in <module>
from _sqlite3 import *
ImportError: DLL load failed: The specified module could not be found.
System:
Windows 10
SublimeText3 (freshly reinstalled during troubleshooting)
Python 3.7.3 [MSC v.1915 64 bit (AMD64)] :: Anaconda, Inc. on win32
(freshly reinstalled during troubleshooting)
Both commandline and ST3 or pointing to same instance of Python.
This is the only python install on the machine.
Have used default Python build in ST3 and created a new build, both have same issue.
Results when using the commandline:
Python 3.7.3 (default, Mar 27 2019, 17:13:21) [MSC v.1915 64 bit (AMD64)] :: Anaconda, Inc. on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import plotly
>>>
Results in ST3:
import plotly
Traceback (most recent call last):
File "C:\Users\usr\Desktop\scrap.py", line 1, in <module>
import plotly
File "C:\ProgramData\anaconda3\Lib\site-packages\plotly\__init__.py", line 32, in <module>
from plotly import (
File "C:\ProgramData\anaconda3\Lib\site-packages\plotly\graph_objs\__init__.py", line 3, in <module>
from plotly.basedatatypes import BaseLayoutType as _BaseLayoutType
File "C:\ProgramData\anaconda3\Lib\site-packages\plotly\basedatatypes.py", line 25, in <module>
from .callbacks import (Points, InputDeviceState)
File "C:\ProgramData\anaconda3\Lib\site-packages\plotly\callbacks.py", line 2, in <module>
from plotly.utils import _list_repr_elided
File "C:\ProgramData\anaconda3\Lib\site-packages\plotly\utils.py", line 262, in <module>
from chart_studio.utils import *
File "C:\ProgramData\anaconda3\Lib\site-packages\chart_studio\__init__.py", line 2, in <module>
from chart_studio import (plotly, dashboard_objs, grid_objs, session)
File "C:\ProgramData\anaconda3\Lib\site-packages\chart_studio\plotly\__init__.py", line 10, in <module>
from . plotly import (
File "C:\ProgramData\anaconda3\Lib\site-packages\chart_studio\plotly\plotly.py", line 38, in <module>
from chart_studio.plotly import chunked_requests
File "C:\ProgramData\anaconda3\Lib\site-packages\chart_studio\plotly\chunked_requests\__init__.py", line 1, in <module>
from . chunked_request import Stream
File "C:\ProgramData\anaconda3\Lib\site-packages\chart_studio\plotly\chunked_requests\chunked_request.py", line 4, in <module>
import ssl
File "C:\ProgramData\anaconda3\Lib\ssl.py", line 98, in <module>
import _ssl # if we can't import it, let the error propagate
ImportError: DLL load failed: The specified module could not be found.
[Finished in 2.9s]
Any help much appreciated, been stuck on this for days.
For those with a similar issue in the future, I've fixed this by uninstalling the Anaconda distribution of Python and replacing it with a base Python installation from Python.org, then installing packages using pip manually. While not the ideal solution, this has solved the issue so that when I build a Python script in ST3, all modules are imported fine.
I have installed pygtk-all-in-one-2.24.0.win32-py2.7.msi on windows, and installed gaphor by easy_install. When I try to run gaphor, I receive an import error.
PS C:\Python27\Scripts> .\gaphor.exe
Traceback (most recent call last):
File "C:\Python27\Scripts\gaphor-script.py", line 9, in <module>
load_entry_point('gaphor==0.17.2', 'console_scripts', 'gaphor')()
File "build\bdist.win32\egg\pkg_resources\__init__.py", line 521, in load_entry_point
File "build\bdist.win32\egg\pkg_resources\__init__.py", line 2632, in load_entry_point
File "build\bdist.win32\egg\pkg_resources\__init__.py", line 2312, in load
File "build\bdist.win32\egg\pkg_resources\__init__.py", line 2318, in resolve
File "C:\Python27\lib\site-packages\gaphor-0.17.2-py2.7.egg\gaphor\__init__.py", line 13, in <module>
import pygtk
ImportError: No module named pygtk
Any suggestions would be appreciated!
Did you actually install pygtk? I suspect easy-install should have pulled it in automatically. Did you see any errors during the install? pygtk also requieres installing gtk+.
Do a simple test - start Python in a console (ipython?), and type:
$ python
Python 2.7.6 (default, May 6 2014, 10:57:58)
[GCC 4.8.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import pygtk
>>> import gtk
>>>
There should be no error messages.
You can also search the disk for pygtk.py (with the file manager) and for a directory gtk-2.0 or gtk-3.0.
I am trying to make exe using py2exe in Python. When I import py2exe I am getting error like this:
Python 2.7.6 (default, Nov 10 2013, 19:24:18) [MSC v.1500 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import py2exe
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Python27\lib\site-packages\py2exe-0.9.2.0-py2.7-win32.egg\py2exe\__init__.py", line 9, in <module>
patch_distutils()
File "C:\Python27\lib\site-packages\py2exe-0.9.2.0-py2.7-win32.egg\py2exe\patch_distutils.py", line 68, in patch_distutils
from . import distutils_buildexe
File "C:\Python27\lib\site-packages\py2exe-0.9.2.0-py2.7-win32.egg\py2exe\distutils_buildexe.py", line 91, in <module>
from . import runtime
File "C:\Python27\lib\site-packages\py2exe-0.9.2.0-py2.7-win32.egg\py2exe\runtime.py", line 3, in <module>
from .dllfinder import Scanner, pydll
File "C:\Python27\lib\site-packages\py2exe-0.9.2.0-py2.7-win32.egg\py2exe\dllfinder.py", line 7, in <module>
from importlib.machinery import EXTENSION_SUFFIXES
ImportError: No module named machinery
Can any body help me fixing this out. I am not getting machinery module any where.
I just ran into this myself. I had installed 0.9 from pypi as well. If you look at the pypi page here py2exe on pypi, you'll see that the download only supports Python 3.3 and later and you should use the 0.6 download from here. I deleted the 0.9 egg after installing 0.6 and it worked after that.
I had same issue, because i had version py2exe0.9 and it is not supported for python2.7.
I downloaded lower version from here http://sourceforge.net/projects/py2exe/files/py2exe/0.6.9/py2exe-0.6.9.win32-py2.7.exe/download
and it works.
I am trying to run the following script in my virtualenv:
(python2.7.2-gonvaled1)gonvaled#lycaon:~/.virtualenvs/python2.7.2-gonvaled1$ couchy.py
Traceback (most recent call last):
File "/home/gonvaled/projects/bin/couchy.py", line 46, in <module>
from couchdb_support import CouchdbLists
File "/home/gonvaled/projects/test_project/python_modules/couchdb_support.py", line 3615, in <module>
from asterisk_support import AsteriskSupport
File "/home/gonvaled/projects/test_project/python_modules/asterisk_support.py", line 4, in <module>
from starpy_support import AmiCommand
File "/home/gonvaled/projects/test_project/python_modules/starpy_support.py", line 7, in <module>
from starpy import manager, fastagi, utilapplication, menu
File "/usr/lib/python2.5/site-packages/starpy/utilapplication.py", line 2, in <module>
from basicproperty import common, propertied, basic, weak
File "/usr/lib/python2.5/site-packages/basicproperty-0.6.12a-py2.5-linux-i686.egg/basicproperty/common.py", line 159, in <module>
from basictypes import datedatetime_types as ddt
File "/usr/lib/python2.5/site-packages/basicproperty-0.6.12a-py2.5-linux-i686.egg/basictypes/datedatetime_types.py", line 4, in <module>
from dateutil import parser
File "/usr/lib/python2.5/site-packages/python_dateutil-2.1-py2.5.egg/dateutil/parser.py", line 8
from __future__ import unicode_literals
SyntaxError: future feature unicode_literals is not defined
So somehow python is trying to import from:
/usr/lib/python2.5/site-packages/starpy/utilapplication.py
This does not make any sense. My virtualenv is very clean:
(python2.7.2-gonvaled1)gonvaled#lycaon:~/.virtualenvs/python2.7.2-gonvaled1$ python
Python 2.7.2 (default, Mar 29 2012, 00:31:29)
[GCC 4.2.4 (Ubuntu 4.2.4-1ubuntu4)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.path
['', '/home/gonvaled/.virtualenvs/python2.7.2-gonvaled1/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg', '/home/gonvaled/.virtualenvs/python2.7.2-gonvaled1/lib/python2.7/site-packages/pip-1.1-py2.7.egg', '/home/gonvaled/.virtualenvs/python2.7.2-gonvaled1/lib/python2.7/site-packages/Twisted-12.0.0-py2.7-linux-i686.egg', '/home/gonvaled/.virtualenvs/python2.7.2-gonvaled1/lib/python2.7/site-packages/zope.interface-3.8.0-py2.7-linux-i686.egg', '/home/gonvaled/.virtualenvs/python2.7.2-gonvaled1/lib/python2.7/site-packages/basicproperty-0.6.12a-py2.7-linux-i686.egg', '/home/gonvaled/projects/gonvaled_settings', '/home/gonvaled/django_apps', '/home/gonvaled/projects/test_project/ipc', '/home/gonvaled/projects/test_project/python_modules', '/home/gonvaled/projects/test_project/gdata', '/home/gonvaled/projects/callisto/libraries', '/home/gonvaled/.virtualenvs/python2.7.2-gonvaled1', '/home/gonvaled/.virtualenvs/python2.7.2-gonvaled1/lib/python27.zip', '/home/gonvaled/.virtualenvs/python2.7.2-gonvaled1/lib/python2.7', '/home/gonvaled/.virtualenvs/python2.7.2-gonvaled1/lib/python2.7/plat-linux2', '/home/gonvaled/.virtualenvs/python2.7.2-gonvaled1/lib/python2.7/lib-tk', '/home/gonvaled/.virtualenvs/python2.7.2-gonvaled1/lib/python2.7/lib-old', '/home/gonvaled/.virtualenvs/python2.7.2-gonvaled1/lib/python2.7/lib-dynload', '/usr/local/python/2.7.2/lib/python2.7', '/usr/local/python/2.7.2/lib/python2.7/plat-linux2', '/usr/local/python/2.7.2/lib/python2.7/lib-tk', '/home/gonvaled/.virtualenvs/python2.7.2-gonvaled1/lib/python2.7/site-packages']
And:
(python2.7.2-gonvaled1)gonvaled#lycaon:~/.virtualenvs/python2.7.2-gonvaled1$ pip freeze
CouchDB==0.9dev
DateUtils==0.5.1
Twisted==12.0.0
basicproperty==0.6.12a
pystache==0.4.0
python-dateutil==2.1
pytz==2012b
simplejson==2.4.0
six==1.1.0
starpy==1.0.0a12
wsgiref==0.1.2
zope.interface==3.8.0
So to summarize: python is importing from /usr/lib/python2.5/site-packages even though I am inside a virtualenv. How can this be?
Try running the script as:
$ python couch.py
in your activated virtualenv. Depending on your system and the first line (the shebang line) of the file, you may not be running in the Python you think you are.
You should create your virtualenv with the --nositepackages option to keep it clean and away from your system Python.