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
Related
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 can't seem to get WeasyPrint to work on Windows with Python 3.4 or 3.5. Has anyone been able to do this? There aren't forums at weasyprint.org and the IRC channel is dead.
I've been able to install using both Python 3.4.3 and 3.5.1. I've followed the guideline found here [1]. I've also made note that WeasyPrint's site claims it should work with Python 2.6+ or 3.1+.
When I install for Python 3.4.3 and open the Python shell and simply 'import weasyprint' I get this:
C:\Python34>python
Python 3.4.3 (v3.4.3:9b73f1c3e601, Feb 24 2015, 22:43:06) [MSC v.1600 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import weasyprint
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Python34\lib\site-packages\weasyprint\__init__.py", line 337, in <module>
from .html import find_base_url, HTML5_UA_STYLESHEET, get_html_metadata # noqa
File "C:\Python34\lib\site-packages\weasyprint\html.py", line 41, in <module>
HTML5_UA_STYLESHEET = CSS(filename=os.path.join(root, 'css', 'html5_ua.css'))
File "C:\Python34\lib\site-packages\weasyprint\__init__.py", line 224, in __init__
with result as (source_type, source, base_url, protocol_encoding):
File "C:\Python34\lib\contextlib.py", line 59, in __enter__
return next(self.gen)
File "C:\Python34\lib\site-packages\weasyprint\__init__.py", line 294, in _select_source
base_url = path2url(filename)
File "C:\Python34\lib\site-packages\weasyprint\urls.py", line 87, in path2url
path = pathname2url(path)
File "C:\Python34\lib\nturl2path.py", line 46, in pathname2url
if not ':' in p:
TypeError: 'str' does not support the buffer interface
>>>
I get a similar traceback when importing in Python 3.5.1, with the exception of the final TypeError being:
TypeError: a bytes-like object is required, not 'str'
[1] https://gist.github.com/doobeh/3188318
I had looked through the issues list at weasyprint.org and didn't find anyone else complaining about Python 3.x compatibility with WeasyPrint. Then I happened upon a pull request that did complain about just that and mirrors my difficulties exactly. So off the shelf it does not work with Python 3.x, but with a small hack it does, see [1]. I'll add some comments to the pull request and hopefully this incompatibility will get looked at.
[1] https://github.com/Kozea/WeasyPrint/pull/132
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 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!
I am trying to run python from a network share on windows 7.
The network share is T:
>t:\python-2.6.1\python
Python 2.6.1 (r261:67517, Dec 4 2008, 16:51:00) [MSC v.1500 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import httplib2
httplib2\__init__.py:29: DeprecationWarning: the md5 module is deprecated; use hashlib instead
import md5
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "T:\python-2.6.1\lib\python2.6\site-packages\httplib2\__init__.py", line 36, in <module>
import httplib
File "T:\python-2.6.1\lib\httplib.py", line 77, in <module>
import mimetools
File "T:\python-2.6.1\lib\mimetools.py", line 6, in <module>
import tempfile
File "T:\python-2.6.1\lib\tempfile.py", line 34, in <module>
from random import Random as _Random
File "T:\python-2.6.1\lib\random.py", line 871, in <module>
_inst = Random()
File "T:\python-2.6.1\lib\random.py", line 96, in __init__
self.seed(x)
File "T:\python-2.6.1\lib\random.py", line 110, in seed
a = long(_hexlify(_urandom(16)), 16)
WindowsError: [Error 127] The specified procedure could not be found
When I copy python-2.6.1 to my local drive it works fine. It also works fine on my windows XP machine using the same network share.
Peter,
When I copy python-2.6.1 from the network share to my local drive it works fine. It also works fine on my windows XP machine using the same network share.