DEAP / deap

Distributed Evolutionary Algorithms in Python
http://deap.readthedocs.org/
GNU Lesser General Public License v3.0
5.75k stars 1.12k forks source link

SyntaxError: invalid syntax #537

Open nbro opened 3 years ago

nbro commented 3 years ago

I forked deap, cloned my fork and I tried to install the cloned version with python setup.py install inside a conda environment with Python 3.7. Then I try to run an example, even with just the import from deap import base, and I get the error

Traceback (most recent call last):
  File "/path/deap/example.py", line 3, in <module>
    from deap import base
  File "/path/deap/deap/base.py", line 193
    raise TypeError, ("Both weights and assigned values must be a "
                   ^
SyntaxError: invalid syntax

This is, of course, due to the fact that deap is not written for 3.7, as can be seen here, where that syntax is not supported in Python 3.7. As far as I understand, deap uses the option use_2to3=True to convert this code written in Python 2 to Python 3 during the installation, however, either if I install my cloned version with python setup.py install or pip install -e ., this option is not applied, so I cannot run the code in editable mode.

So, what's your approach to edit/develop deap in Python 3? I would like to change something in deap (i.e. add a feature), but I'm not sure what's the right approach here.

(By the way, you may consider not supporting Python 2 anymore, given it's officially not supported by Python developers anymore: apparently, you have already been discussing this: https://github.com/DEAP/deap/pull/408. Deap is mainly used for research and nobody in research is probably using Python 2 anymore. I would really suggest that a new version of Deap should be rewritten in Python 3 so that we can get rid of all this useless burden.)

fmder commented 3 years ago

unfortunately -e does not support 2to3.

nbro commented 3 years ago

@fmder So, what's your approach to developing Deap in Python 3?

microprediction commented 2 years ago

I'm also having problems caused by 2to3.

fmder commented 2 years ago

I'm rewriting the whole thing in python3, but that take way more time than I have 😞

meghkc commented 2 years ago

I am having exactly same problem. even I am using python 3.10 what should we do to get rid pf this problem? I was having problem with installing deap 1.3.1 initially but it solved after demoting the setup tools version to 58.0.0 pip is 22.1.1 version deap library

julien-blanchon commented 2 years ago

+1