Python Forum
Thread Rating:
  • 3 Vote(s) - 2.33 Average
  • 1
  • 2
  • 3
  • 4
  • 5
AttributeError when
#1
using python3.6 and i'm trying to use pycharm as my IDE. below code works well on the interpreter from command list but not from pycharm.
any help appreciated ?

import tarfile

with tarfile.open("sample.tar","w") as tar:
    for name in [ "foo", "bar", "quux"]:
        tar.add(name)
.
.
Error:
with tarfile.open("sample.tar","w") as tar: AttributeError: module 'tarfile' has no attribute 'open'
Reply
#2
I tried it and it works fine with python3.4
I did use real file names in place of 'foo', 'bar' and 'quix'
(which you would need for it to work.

Try changing those to real files and see if it works.
Reply
#3
Have you written your own tarfile.py, by any chance?
Unless noted otherwise, code in my posts should be understood as "coding suggestions", and its use may require more neurones than the two necessary for Ctrl-C/Ctrl-V.
Your one-stop place for all your GIMP needs: gimp-forum.net
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020