I am trying to create tempfile but my python versions do not allow me to proceed and give the following complaints. Do I need to upgrade this version to use tempfile module. Thanks
Python 2.4.3 (#1, Jan 9 2013, 06:47:03) [GCC 4.1.2 20080704 (Red Hat 4.1.2-54)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import tempfile
Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "tempfile.py", line 2, in ?
temp = tempfile.NamedTemporaryFile()
AttributeError: 'module' object has no attribute 'NamedTemporaryFile'
You are importing a local file. You have a file named tempfile.py
in your local directory that masks the global module. import tempfile
imports that file, not the standard library module.
Use print tempfile.__file__
to locate that file if you cannot find it. Rename that file to something else.
The Python 2.4 tempfile
module supports NamedTemporaryFile
without upgrading.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.