The example_clustering_2.py not working
I have installed PYGAD with pip and tried to run the example_clustering_2.py and it gives the following error:
File "/home/GeneticAlgorithmPython/example_clustering_2.py", line 3, in <module>
import pygad
File "/home/GeneticAlgorithmPython/pygad.py", line 9, in <module>
from pygad import utils
ImportError: cannot import name 'utils' from partially initialized module 'pygad' (most likely due to a circular import) (/home/GeneticAlgorithmPython/pygad.py)
Please consider installing PyGAD using pip if not already installed.
Then run the example_clustering_2.py script outside of the cloned repository directory. It imports the pygad.py module in this directory.
Thanks a lot, I have got it working when using standard pip install. However, when I install it from the git repo using pip install -e . the same error pops up.
The GitHub repository does not have the complete package. We are working in to have all the modules in the library in another branch before merging it. At the moment, the modules are split into multiple repositories.
Moreover, even running the example_clustering_2.py script in a folder containing the pygad.py module, the same issue will rise. This is because Python searches for the module in the same folder first. If found, then it uses it and will not use the installed library in the site-packages folder.
The way it works is by installing the library using pip install --upgrade pygad and the script will definitely work.
Sure, I will wait for the release than. I need to install it with the git repo since I need to work on a optimization with a complex data structure that cannot be done with an Numpy array. I need to modify the file to do what I need to do.
You can still modify the code locally after installing the library using pip.
Just locate the installation directory in the site-packages folder. Then edit the code.
This is not recommended, but this will do for now. Thanks a lot. By the way, would you be interested in improving the formatting of the code and including typing to the library? I am happy to contribute if you are interested.
You are completely welcome to contribute. Just create a pull request of your contributions. Thanks a lot.