AttributeError: 'module' object has no attribute 'python_2_unicode_compatible'

1,223 views
Skip to first unread message

Heidi Frank

unread,
Feb 22, 2016, 4:44:50 PM2/22/16
to pymarc Discussion
Hi everyone,
I've just started to work with python/pymarc on a new computer and used pip to install pymarc (using Python 2.7.10), but when I've just tried to run a python script, I get the following error for the "import pymarc" line:

172-16-245-249:bin hf36$ python aco-1-xml2mrc-oclc-nums.py

Traceback (most recent call last):

  File "aco-1-xml2mrc-oclc-nums.py", line 9, in <module>

    import pymarc

  File "/Library/Python/2.7/site-packages/pymarc/__init__.py", line 62, in <module>

    from .record import *

  File "/Library/Python/2.7/site-packages/pymarc/record.py", line 31, in <module>

    @six.python_2_unicode_compatible

AttributeError: 'module' object has no attribute 'python_2_unicode_compatible'



I assume I've something out of date or such, but have no idea how to troubleshoot this error... (I'm not that versed in installation issues)

please let me know if you've ideas how to resolve.
thanks in advance!!
heidi

Heidi Frank
Electronic Resources & Special Formats Cataloger
New York University Libraries
Knowledge Access & Resources Management Services
20 Cooper Square, 3rd Floor
New York, NY  10003
212-998-2499 (office)
212-995-4366 (fax)
hf...@nyu.edu
Skype: hfrank71

Ed Summers

unread,
Feb 22, 2016, 10:03:45 PM2/22/16
to pym...@googlegroups.com
Hi Heidi,

Did the pip installation go ok? If it did it should have installed a version of the six module, that is greater than v1.9.0. I think I've seen that error from previous versions of the six module.

Could you confirm what version of six you have installed by doing this:

```
% python
Python 2.7.10 (default, Oct 23 2015, 18:05:06)
[GCC 4.2.1 Compatible Apple LLVM 7.0.0 (clang-700.0.59.5)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import six
>>> six.__version__
'1.9.0'
```

Thanks!

//Ed

signature.asc

Heidi P Frank

unread,
Feb 23, 2016, 8:04:28 AM2/23/16
to pym...@googlegroups.com
Hi Ed,
I *think* the pip installation went fine - I downloaded the "get-pip.py" file (attached) and ran the script using:
python get-pip.py

and then I ran:
sudo pip install pymarc

and that seemed to work fine too.  I then cloned my git repository and tried to run my python/pymarc script, that's when I got the error.

I've just tried what you suggested, but my "six.__version__" says 1.4.1 instead of 1.9.0...
172-16-245-249:bin hf36$ python
Python 2.7.10 (default, Jul 14 2015, 19:46:27)
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.39)] on darwin

Type "help", "copyright", "credits" or "license" for more information.
>>> import six
>>> six.__version__
'1.4.1'
>>>

do you think I just need to upgrade "six"?    I've looked at a number of sites online, and see lots of various suggestions - e.g., first uninstall six, then upgrade, or just run a command to upgrade, such as:
pip install --upgrade six
or
python -m pip install --upgrade six
or
pip install six --upgrade
or
pip install six -U
...etc

would any of these commands do the same thing?  (if indeed I just need to upgrade six?)

thanks for the help!!
heidi


Heidi Frank
Electronic Resources & Special Formats Cataloger
New York University Libraries
Knowledge Access & Resources Management Services
20 Cooper Square, 3rd Floor
New York, NY  10003
212-998-2499 (office)
212-995-4366 (fax)
hf...@nyu.edu
Skype: hfrank71


//Ed

--
You received this message because you are subscribed to a topic in the Google Groups "pymarc Discussion" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/pymarc/iEUvHQmbghc/unsubscribe.
To unsubscribe from this group and all its topics, send an email to pymarc+un...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

get-pip.py

Geoffrey Spear

unread,
Feb 23, 2016, 9:02:17 AM2/23/16
to pym...@googlegroups.com
Heidi,

You probably want "sudo pip install -U six"

(Note: I wouldn't suggest running pip with sudo at all ever, but since you'd already installed it as root, you can only replace it as root. In the future I'd strongly suggest using virtualenv or the --user flag to pip to install modules. Messing with the system python isn't a great idea even if you trust the arbitrary code from the internet you're running as root not to do anything malicious on purpose...)

--
You received this message because you are subscribed to the Google Groups "pymarc Discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pymarc+un...@googlegroups.com.

Heidi P Frank

unread,
Feb 23, 2016, 10:16:11 AM2/23/16
to pym...@googlegroups.com
Hi Geoffrey,
Thanks very much for the feedback!   I'm using a laptop from work and even though I'm the only user on it and have the admin password, it seems I have to use "sudo" for the install commands or it says I don't have permissions (I admittedly don't understand that side of things)   my IT dept at work had installed python and I'm still not that familiar with other setups, like virtualenv, etc. so haven't tried to change anything except to get pymarc working.

I did just run the upgrade command for six and it seemed to work and installed 1.10.0...
------------------------------------------------
172-16-245-249:bin hf36$ python
Python 2.7.10 (default, Jul 14 2015, 19:46:27) 
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.39)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import six
>>> six.__version__
'1.4.1'
>>> exit()
172-16-245-249:bin hf36$ sudo pip install -U six
Password:
The directory '/Users/hf36/Library/Caches/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
The directory '/Users/hf36/Library/Caches/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Collecting six
  Downloading six-1.10.0-py2.py3-none-any.whl
Installing collected packages: six
  Found existing installation: six 1.4.1
    DEPRECATION: Uninstalling a distutils installed project (six) has been deprecated and will be removed in a future version. This is due to the fact that uninstalling a distutils project will only partially uninstall the project.
    Uninstalling six-1.4.1:
      Successfully uninstalled six-1.4.1
Successfully installed six-1.10.0
------------------------------------------------


but then when I tried to run my python script that uses pymarc, I get the same error as before  :(
------------------------------------------------
172-16-245-249:bin hf36$ python aco-3-process.py
Traceback (most recent call last):
  File "aco-3-process.py", line 9, in <module>
    import pymarc
  File "/Library/Python/2.7/site-packages/pymarc/__init__.py", line 62, in <module>
    from .record import *
  File "/Library/Python/2.7/site-packages/pymarc/record.py", line 31, in <module>
    @six.python_2_unicode_compatible
AttributeError: 'module' object has no attribute 'python_2_unicode_compatible'
------------------------------------------------

any other ideas what to try?
h


Heidi Frank
Electronic Resources & Special Formats Cataloger
New York University Libraries
Knowledge Access & Resources Management Services
20 Cooper Square, 3rd Floor
New York, NY  10003
212-998-2499 (office)
212-995-4366 (fax)
hf...@nyu.edu
Skype: hfrank71

Mirek Zvolsky

unread,
May 3, 2016, 5:48:30 AM5/3/16
to pymarc Discussion
Same error: 'module' object has no attribute 'python_2_unicode_compatible'
In my case
pip install six --upgrade
was real help.
Thanks.
(Debian/Jessie/stable, Py 2.7.9)


Dne pondělí 22. února 2016 22:44:50 UTC+1 Heidi Frank napsal(a):

Geoffrey Spear

unread,
May 3, 2016, 10:27:24 AM5/3/16
to pym...@googlegroups.com
I've sent a pull request to correct the setup.py; it seems that only the requirements.txt file was aware of the minimum version of six required by pymarc, and installing with pip won't upgrade six if it's already installed.

--

Ed Summers

unread,
May 3, 2016, 10:47:37 AM5/3/16
to pym...@googlegroups.com
I just merged the pull request and released v3.1.2 on PyPI. If you update your pymarc with pip maybe things will "just work" now?

pip install -U pymarc

//Ed

PS. Thanks Geoffrey!
Reply all
Reply to author
Forward
0 new messages