Not my code, I was trying a tool that includes the osascript library.
In the lib, at the line path = temp.tempfile()
the error in the title is raised.
The temp library, correctly imported by the authors, has the following code itself:
f, path = tempfile.mkstemp()
The tempfile.mkstemp()
part works like a charm.
So, since we are talking about two very common and widely used libs and since I'm apparently unable to find anything relevant on Google, I'm kind pretty sure there's some problem with my local configuration.
I'm on macOS, using python3 (3.7), no virtual envs.
The command pip list --outdated
tells me that exactly those two libs are actually outdated, but apparently there is no way pip will download the updated versions. (note: my pip is correctly referring to the python3 binary, not macOS outdated python 2.7)
osascript 0.0.0 2020.7.2 sdist
temp 0.0.0 2020.7.1 sdist
Any ideas?
Steps to reproduce the error:
>>> import temp
>>> temp.tempfile()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.7/site-packages/temp/__init__.py", line 15, in tempfile
f, path = tempfile.mkstemp()
AttributeError: 'function' object has no attribute 'mkstemp'
temp.py
of your own (or other such conflicting name) that's being imported instead of the actual module?find
research on the whole disk and the only occurrence that popped out was a file from Django (which I use on a totally different project):/usr/local/lib/python3.7/site-packages/django/core/files/temp.py
. Pretty sure that this file is not mistakenly imported by the osascript lib. But thanks, yours is definitely a good tip.