import MultiNEAT as NEAT need to install MultiNEAT. Tried to install using these instructions https://github.com/peter-ch/MultiNEAT it said success despite this: byte-compiling build/bdist.linux-x86_64/egg/MultiNEAT/init.py to init.pyc File "build/bdist.linux-x86_64/egg/MultiNEAT/init.py", line 45 t = {**traits, 'w':w} ^ SyntaxError: invalid syntax Installed /usr/local/lib/python2.7/dist-packages/multineat-0.5-py2.7-linux-x86_64.egg Processing dependencies for multineat==0.5 Finished processing dependencies for multineat==0.5 then tried pip install . https://stackoverflow.com/questions/1471994/what-is-setup-py It gets these errors: /usr/bin/ld: cannot find -lboost_python36 /usr/bin/ld: cannot find -lboost_numpy36
boost libs missing. Apparently it has a conda install, but I don’t entirely understand whether conda and pip will play nicely together. conda also a big install and the Chromebook is not big on space. Ok Miniconda is smaller.
https://anaconda.org/conda-forge/multineat
To install this package with conda run one of the following:
conda install -c conda-forge multineat
conda install -c conda-forge/label/cf201901 multineat
conda install -c conda-forge/label/cf202003 multineat
apt-get install libboost-all-dev
...already installed
https://stackoverflow.com/questions/36881958/c-program-cannot-find-boost possible solution.
ah…
/usr/local/lib/python2.7/dist-packages
root@chrx:/opt/MultiNEAT# ls -l /usr/local/lib/python2.7/dist-packages
total 7312
-rw-r–r– 1 root staff 39 Apr 8 21:50 easy-install.pth
-rw-r–r– 1 root staff 7482106 Apr 8 21:50 multineat-0.5-py2.7-linux-x86_64.egg
so it’s compiling with python2.
I’m gonna go with conda instead.
conda install MultiNEAT
https://anaconda.org/conda-forge/multineat
https://docs.conda.io/en/latest/miniconda.html#linux-installers
you need to chmod 755 the install file, and don’t forget to add to $PATH.
echo “PATH=$PATH:/opt/miniconda3/bin” >> ~/.bashrc
then close window and open new bash window, to refresh envs. (envs are environment variables, if someone is actually reading this)
conda install -c conda-forge multineat
(base) root@chrx:~# conda install -c conda-forge multineat
Collecting package metadata (current_repodata.json): done
Solving environment: failed with initial frozen solve. Retrying with flexible solve.
Solving environment: failed with repodata from current_repodata.json, will retry with next repodata source.
Collecting package metadata (repodata.json): done
Solving environment: failed with initial frozen solve. Retrying with flexible solve.
Solving environment: |
Found conflicts! Looking for incompatible packages.
This can take several minutes. Press CTRL-C to abort.
failed
UnsatisfiableError: The following specifications were found
to be incompatible with the existing python installation in your environment:
Specifications:
- multineat -> python[version='>=2.7,<2.8.0a0|>=3.6,<3.7.0a0|>=3.5,<3.6.0a0']
Your python: python=3.7
If python is on the left-most side of the chain, that's the version you've asked for.
When python appears to the right, that indicates that the thing on the left is somehow
not available for the python version you are constrained to. Note that conda will not
change your python version to a different minor version unless you explicitly specify
that.
ok…
root@chrx:~# conda info
active environment : base
active env location : /opt/miniconda3
shell level : 1
user config file : /root/.condarc
populated config files : /root/.condarc
conda version : 4.8.2
conda-build version : not installed
python version : 3.7.6.final.0
virtual packages : __glibc=2.27
base environment : /opt/miniconda3 (writable)
channel URLs : https://repo.anaconda.com/pkgs/main/linux-64
https://repo.anaconda.com/pkgs/main/noarch
https://repo.anaconda.com/pkgs/r/linux-64
https://repo.anaconda.com/pkgs/r/noarch
package cache : /opt/miniconda3/pkgs
/root/.conda/pkgs
envs directories : /opt/miniconda3/envs
/root/.conda/envs
platform : linux-64
user-agent : conda/4.8.2 requests/2.22.0 CPython/3.7.6 Linux/4.16.18-galliumos galliumos/3.1 glibc/2.27
UID:GID : 0:0
netrc file : None
offline mode : False
ok let’s go back to compiling boost from source cause conda don’t like 3.7. Which seems like I should do a –force or something, cause wtf. So here’s the theory of C++ linking (fml):
https://stackoverflow.com/questions/16710047/usr-bin-ld-cannot-find-lnameofthelibrary
here’s more relevant
https://stackoverflow.com/questions/12578499/how-to-install-boost-on-ubuntu
Here’s some Dockerfile on it:
RUN cd /usr/src && \
wget --no-verbose https://dl.bintray.com/boostorg/release/1.65.1/source/boost_1_65_1.tar.gz && \
tar xzf boost_1_65_1.tar.gz && \
cd boost_1_65_1 && \
ln -s /usr/local/include/python3.6m /usr/local/include/python3.6 && \
./bootstrap.sh --with-python=$(which python3) && \
./b2 install && \
rm /usr/local/include/python3.6 && \
ldconfig && \
cd / && rm -rf /usr/src/*
I’m doing the steps one by one, ./b2 made it compile. it’s taking like a good few mins now.
The Boost C++ Libraries were successfully built!
The following directory should be added to compiler include paths:
/opt/boost_1_65_1
The following directory should be added to linker library paths:
/opt/boost_1_65_1/stage/lib
ok let’s try again…
/usr/bin/ld: cannot find -lboost_python36
/usr/bin/ld: cannot find -lboost_numpy36
ldconfig
nope ok where is the library?
# find | grep boost_python
(there's all the boost libs i built under /opt, and also these:)
./usr/lib/x86_64-linux-gnu/libboost_python-py36.so
./usr/lib/x86_64-linux-gnu/libboost_python3-py36.so.1.65.1
./usr/lib/x86_64-linux-gnu/libboost_python-py27.so.1.65.1
./usr/lib/x86_64-linux-gnu/libboost_python3-py36.so
./usr/lib/x86_64-linux-gnu/libboost_python-py27.a
./usr/lib/x86_64-linux-gnu/libboost_python-py36.a
./usr/lib/x86_64-linux-gnu/libboost_python.so
./usr/lib/x86_64-linux-gnu/libboost_python3.a
./usr/lib/x86_64-linux-gnu/libboost_python-py27.so
./usr/lib/x86_64-linux-gnu/libboost_python3.so
./usr/lib/x86_64-linux-gnu/libboost_python3-py36.a
./usr/lib/x86_64-linux-gnu/libboost_python.a
Ok ./usr/lib/x86_64-linux-gnu/ is where the .so is.
https://stackoverflow.com/questions/3808775/cmake-doesnt-find-boost
https://stackoverflow.com/questions/36881958/c-program-cannot-find-boost
the last one had the sauce that worked for someone for something similar
So I’m changing this bit of setup.py
include_dirs = ['/opt/boost_1_65_1']
library_dirs = ['/opt/boost_1_65_1/stage/lib']
extra.extend(['-DUSE_BOOST_PYTHON', '-DUSE_BOOST_RANDOM', #'-O0',
#'-DVDEBUG',
])
exx = Extension('MultiNEAT._MultiNEAT',
sources,
libraries=libs,
library_dirs=library_dirs,
include_dirs=include_dirs,
extra_compile_args=extra)
nope
So we need to use LD somehow.
You need:
- To actually have the library in your computer
- Help gcc/the linker to find the library by providing the path to the library
- You can add
-Ldir-name
to thegcc
command - You can the library location to the
LD_LIBRARY_PATH
environment variable
- You can add
- Update the “Dynamic Linker“:
sudo ldconfig
Let’s see what it’s running…
x86_64-linux-gnu-g++ -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,-Bsymbolic-functions -Wl,-z,relro -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 build/temp.linux-x86_64-3.6/src/PythonBindings.o build/temp.linux-x86_64-3.6/src/Genome.o build/temp.linux-x86_64-3.6/src/Innovation.o build/temp.linux-x86_64-3.6/src/NeuralNetwork.o build/temp.linux-x86_64-3.6/src/Parameters.o build/temp.linux-x86_64-3.6/src/PhenotypeBehavior.o build/temp.linux-x86_64-3.6/src/Population.o build/temp.linux-x86_64-3.6/src/Random.o build/temp.linux-x86_64-3.6/src/Species.o build/temp.linux-x86_64-3.6/src/Substrate.o build/temp.linux-x86_64-3.6/src/Utils.o -L/opt/boost_1_65_1/stage/lib -lboost_system -lboost_serialization -lboost_python36 -lboost_numpy36 -o build/lib.linux-x86_64-3.6/MultiNEAT/_MultiNEAT.cpython-36m-x86_64-linux-gnu.so
ok and indeed there doesn’t seem to be anything under /opt/boost_1_65_1/stage/lib with python in the name. We found it in /usr/lib/x86_64-linux-gnu/ earlier.
nope nope nope
https://stackoverflow.com/questions/24173330/cmake-is-not-able-to-find-boost-libraries
SET (BOOST_ROOT "/opt/boost_1_65_1")
SET (BOOST_INCLUDEDIR "/opt/boost_1_65_1/boost")
SET (BOOST_LIBRARYDIR "/opt/boost_1_65_1/libs")
ok so I think it’s just that the Boost.Python package isn’t here. It’s in usr/lib … hmm more later
Here’s something promising: https://github.com/andrewssobral/bgslibrary/issues/96
#:/usr/lib/x86_64-linux-gnu# find | grep boost_python
./libboost_python-py36.so
./libboost_python3-py36.so.1.65.1
./libboost_python-py27.so.1.65.1
./libboost_python3-py36.so
./libboost_python-py27.a
./libboost_python-py36.a
./libboost_python.so
./libboost_python3.a
./libboost_python-py27.so
./libboost_python3.so
./libboost_python3-py36.a
./libboost_python.a
Hmm the answer doesn’t make sense here. Half of those are already symlinks. Let’s go back and make sure we compiled correctly.
./bootstrap.sh --with-libraries=python --with-python=python3.6
export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH
export LD_LIBRARY_PATH=/usr/lib:$LD_LIBRARY_PATH
nope. ok what is cmake doing?
It calls Find.Boost,
dies on :
No header defined for python36; skipping header check
No header defined for numpy36; skipping header check
so, ok i worked it out
I changed the CMakeList.txt line to -lboost_python3 -lboost_numpy3
Installed /usr/local/lib/python3.6/dist-packages/multineat-0.5-py3.6-linux-x86_64.egg
Processing dependencies for multineat==0.5
Finished processing dependencies for multineat==0.5
ok but when i try run a python boi in the examples folder,
Boost.Python.ArgumentError: Python argument types in
Genome.init(Genome, int, int, int, int, bool, ActivationFunction, ActivationFunction, int, Parameters, int)
did not match C++ signature:
init(_object*, unsigned int, unsigned int, unsigned int, unsigned int, bool, NEAT::ActivationFunction, NEAT::ActivationFunction, int, NEAT::Parameters, unsigned int, unsigned int)
ok fuck it, github, help me.
https://github.com/peter-ch/MultiNEAT/issues
Ok so the guy pointed out that the constructor changed. It works fine now, after adding a field.