[MacPorts] #44954: poppler, gobject-introspection: AttributeError: 'module' object has no attribute 'mkstemp'
MacPorts
noreply at macports.org
Thu Nov 13 02:58:45 PST 2014
#44954: poppler, gobject-introspection: AttributeError: 'module' object has no
attribute 'mkstemp'
-------------------------------+----------------------
Reporter: john.m.harrold@… | Owner: devans@…
Type: defect | Status: assigned
Priority: Normal | Milestone:
Component: ports | Version:
Resolution: | Keywords:
Port: poppler |
-------------------------------+----------------------
Comment (by ww.galen@…):
I might have a resolution.
I was getting this error when attempting to upgrade Python 2.7, during
staging. Consequently, the top of the stack in my error message was
different than in John's, but the stack from the `import tempfile` on was
basically the same (the only difference was that modules were located in
the build directory rather than the system directory). I could also get
the same error by starting python 2.7 and trying to import tempfile:
{{{
Python 2.7.8 (default, Jul 16 2014, 01:06:49)
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import tempfile
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File
"/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/tempfile.py",
line 35, in <module>
from random import Random as _Random
File
"/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/random.py",
line 50, in <module>
from hashlib import sha512 as _sha512
File "build/bdist.macosx-10.6-x86_64/egg/hashlib.py", line 105, in
<module>
File "build/bdist.macosx-10.6-x86_64/egg/_hashlib.py", line 7, in
<module>
File "build/bdist.macosx-10.6-x86_64/egg/_hashlib.py", line 4, in
__bootstrap__
File
"/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7
/site-packages/pkg_resources.py", line 937, in resource_filename
self, resource_name
File
"/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7
/site-packages/pkg_resources.py", line 1632, in get_resource_filename
self._extract_resource(manager, self._eager_to_zip(name))
File
"/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7
/site-packages/pkg_resources.py", line 1668, in _extract_resource
outf, tmpnam = _mkstemp(".$extract", dir=os.path.dirname(real_path))
File
"/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7
/site-packages/pkg_resources.py", line 2852, in _mkstemp
return tempfile.mkstemp(*args,**kw)
AttributeError: 'module' object has no attribute 'mkstemp'
}}}
(Sure, 10.6 isn't officially supported by MacPorts, but my Mac won't
officially support anything newer than 10.7.)
It's a cyclic dependency: tempfile loads random, which loads hashlib,
which loads pkg_resources, which calls `tempfile.mkstemp`, which isn't
defined yet. The funny thing is the path for hashlib, which isn't the same
as for the other modules, despite there being a hashlib.py in the same
directory.
What happened (as you might guess from the path) was that I had an egg for
hashlib in the "site-packages" sub-directory seen in the stack above. I:
* removed the reference to the hashlib egg file in "site-packages/easy-
install.pth" (you also may be able to run `easy-install -m hashlib`, but
for me affected a different python installation), then
* renamed the egg (you can probably delete the egg, but renaming is
safer).
After that, python 2.7 staged successfully. I could also import tempfile
and hashlib, so I deleted the egg.
--
Ticket URL: <https://trac.macports.org/ticket/44954#comment:11>
MacPorts <https://www.macports.org/>
Ports system for OS X
More information about the macports-tickets
mailing list