Python Forum
AttributeError: Can't get attribute 'Individual' on <module 'deap.creator' - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: Data Science (https://python-forum.io/forum-44.html)
+--- Thread: AttributeError: Can't get attribute 'Individual' on <module 'deap.creator' (/thread-11831.html)



AttributeError: Can't get attribute 'Individual' on <module 'deap.creator' - DomClout - Jul-27-2018

Hi everyone,

I'm quite new to Python, so excuse me if this question sounds basic, but here it is:

A colleague of mine is now on vacation and I have to access a pickle file (more than one, actually...) filled with data that I have to analyze. First, I used the following line of code to open the file in Python, but without any success...

import numpy as np
import deap
import pickle
import scipy

with open('fronts.pkl','rb') as pickle_file:
    data = pickle.load(pickle_file)
It gives me the following error message:

AttributeError: Can't get attribute 'Individual' on <module 'deap.creator' from 'C:\\python\\lib\\site-packages\\deap\\creator.py'>

I use Python 3.7.0 on my computer, but my colleague used 2.7 on his. Should I downgrade back to 2.7 to fit his version?

I read on another forum about pickle files that one could have problems reading a pickle file that was written on someone else's device. However, I do not have access to my colleague's computer, as it is being used by someone at the moment. It would really be best if I did not monopolize his device, since what I have to do with the data might take a while.

Does anyone have an idea on how to solve this? I've been looking for far too long for what it seems like a insignificant problem...

Thank you!


RE: AttributeError: Can't get attribute 'Individual' on <module 'deap.creator' - Vysero - Jul-27-2018

Do you have access to this 'deep.creator' module? I suppose it could be a py2/py3 conversion problem if 'deep.creator' is using a module that is not longer supported.


RE: AttributeError: Can't get attribute 'Individual' on <module 'deap.creator' - snippsat - Jul-27-2018

(Jul-27-2018, 02:12 PM)DomClout Wrote: I use Python 3.7.0 on my computer, but my colleague used 2.7 on his. Should I downgrade back to 2.7 to fit his version?
No need to downgrade,you just install 2.7 and do add to Path under installation.
Then access trough py,this is file that 3.7 install in Windows folder(py.exe) to access other version.
C:\>python -V
Python 3.7.0

C:\>pip -V
pip 10.0.1 from c:\python37\lib\site-packages\pip (python 3.7)

# Access 2.7 
C:\>py -2.7 -V                                                                                                   
Python 2.7.9 

# Using pip to install to 2.7                                                                            
C:\>py -2.7 -m pip install logzero                                                                               
Requirement already satisfied: logzero in c:\python27\lib\site-packages
So running a script with 2.7 is py -2.7 my_script.py and using pip is py -2.7 -m pip install package_name
3.7 will be as normal with python and pip command python my_script.py and pip install package_name.


RE: AttributeError: Can't get attribute 'Individual' on <module 'deap.creator' - DomClout - Jul-27-2018

snippsat :

I did as you suggested, and when I run the script with 2.7.15, I receive this error message:

>py -2.7 lecture_fronts_idle.py
Traceback (most recent call last):
File "lecture_fronts_idle.py", line 9, in <module>
data = pickle.load(pickle_file)
File "C:\Python27\lib\pickle.py", line 1384, in load
return Unpickler(file).load()
File "C:\Python27\lib\pickle.py", line 864, in load
dispatch[key](self)
File "C:\Python27\lib\pickle.py", line 1096, in load_global
klass = self.find_class(module, name)
File "C:\Python27\lib\pickle.py", line 1132, in find_class
klass = getattr(mod, name)
AttributeError: 'module' object has no attribute 'Individual'

The last line is the same line I get with Python 3.7


RE: AttributeError: Can't get attribute 'Individual' on <module 'deap.creator' - Vysero - Jul-27-2018

(Jul-27-2018, 07:12 PM)DomClout Wrote: snippsat :

I did as you suggested, and when I run the script with 2.7.15, I receive this error message:

>py -2.7 lecture_fronts_idle.py
Traceback (most recent call last):
File "lecture_fronts_idle.py", line 9, in <module>
data = pickle.load(pickle_file)
File "C:\Python27\lib\pickle.py", line 1384, in load
return Unpickler(file).load()
File "C:\Python27\lib\pickle.py", line 864, in load
dispatch[key](self)
File "C:\Python27\lib\pickle.py", line 1096, in load_global
klass = self.find_class(module, name)
File "C:\Python27\lib\pickle.py", line 1132, in find_class
klass = getattr(mod, name)
AttributeError: 'module' object has no attribute 'Individual'

The last line is the same line I get with Python 3.7

Must not be a conversion error. I would attempt looking at that module. Is there a chance that your colleague changes something prior to leaving?