sollan / alma

Fully automated (rodent) limb motion analysis toolbox for behavioral analysis with bodypart coordinate data, building upon markerless pose estimation.
GNU General Public License v3.0
13 stars 5 forks source link

numpy incompatibility with sklearn #18

Closed michaelru2000 closed 2 years ago

michaelru2000 commented 2 years ago

@sollan

Hi, I am trying to install the alma package but I keep running into this error. We created an environment and tested different versions of NumPy with no success. Please advise, thanks in advance.

(alma) Michaels-MacBook-Air-3:alma-master michaelru$ python ./alma.py Traceback (most recent call last): File "./alma.py", line 2, in <module> from Panels import Start, AnalyzeStride, AnalyzeFootfall, RandomForest, PCA File "/Users/michaelru/Downloads/alma-master/Panels/RandomForest.py", line 3, in <module> from Functions import ConfigFunctions, DataAnalysisFunctions File "/Users/michaelru/Downloads/alma-master/Functions/DataAnalysisFunctions.py", line 5, in <module> from sklearn.ensemble import RandomForestClassifier File "/opt/anaconda3/envs/alma/lib/python3.8/site-packages/sklearn/ensemble/__init__.py", line 17, in <module> from ._gb import GradientBoostingClassifier File "/opt/anaconda3/envs/alma/lib/python3.8/site-packages/sklearn/ensemble/_gb.py", line 33, in <module> from ._gradient_boosting import predict_stages File "__init__.pxd", line 918, in init sklearn.ensemble._gradient_boosting RuntimeWarning: numpy.ufunc size changed, may indicate binary incompatibility. Expected 192 from C header, got 216 from PyObject

sollan commented 2 years ago

Hi Michael! What's the python version you are using and which NumPy versions have you tried so far? Could you please provide a list of all packages so that I can try to replicate the error? (such as pip freeze > requirements.txt) Thanks!

Best, Annette

michaelru2000 commented 2 years ago

Hi Annette! Thanks for the quick response. We tried python versions 3.7 and 3.8 and NumPy versions 1.16.1, 1.19.5, and 1.20.3. These are the packages I currently have installed as well is the requirements txt.

# Name Version Build Channel backports 1.0 py_2 conda-forge backports.lzma 0.0.14 py38hba84461_3 conda-forge blas 2.114 openblas conda-forge blas-devel 3.9.0 14_osx64_openblas conda-forge brotli 1.0.9 h5eb16cf_7 conda-forge brotli-bin 1.0.9 h5eb16cf_7 conda-forge brotlipy 0.7.0 py38hed1de0f_1004 conda-forge bzip2 1.0.8 h0d85af4_4 conda-forge ca-certificates 2022.4.26 hecd8cb5_0 anaconda certifi 2021.10.8 py38hecd8cb5_2 anaconda cffi 1.15.0 py38h1a44b6c_0 conda-forge charset-normalizer 2.0.12 pyhd8ed1ab_0 conda-forge cryptography 36.0.2 py38h826b3c8_1 conda-forge cycler 0.11.0 pyhd8ed1ab_0 conda-forge expat 2.4.8 h96cf925_0 conda-forge fastdtw 0.3.4 py38h9bb44b7_0 conda-forge fonttools 4.33.3 py38h0dd4459_0 conda-forge freetype 2.10.4 h4cff582_1 conda-forge gettext 0.19.8.1 hd1a6beb_1008 conda-forge giflib 5.2.1 hbcb3906_2 conda-forge idna 3.3 pyhd8ed1ab_0 conda-forge jbig 2.1 h0d85af4_2003 conda-forge joblib 1.1.0 pyhd8ed1ab_0 conda-forge jpeg 9e h5eb16cf_1 conda-forge kiwisolver 1.4.2 py38h8b7791e_1 conda-forge lcms2 2.12 h577c468_0 conda-forge lerc 3.0 he49afe7_0 conda-forge libblas 3.9.0 14_osx64_openblas conda-forge libbrotlicommon 1.0.9 h5eb16cf_7 conda-forge libbrotlidec 1.0.9 h5eb16cf_7 conda-forge libbrotlienc 1.0.9 h5eb16cf_7 conda-forge libcblas 3.9.0 14_osx64_openblas conda-forge libcxx 14.0.3 hc203e6f_0 conda-forge libdeflate 1.10 h0d85af4_0 conda-forge libffi 3.4.2 h0d85af4_5 conda-forge libgfortran 5.0.0 9_3_0_h6c81a4c_23 conda-forge libgfortran5 9.3.0 h6c81a4c_23 conda-forge libiconv 1.16 haf1e3a3_0 conda-forge liblapack 3.9.0 14_osx64_openblas conda-forge liblapacke 3.9.0 14_osx64_openblas conda-forge libopenblas 0.3.20 openmp_hb3cd9ec_0 conda-forge libpng 1.6.37 h7cec526_2 conda-forge libtiff 4.3.0 h17f2ce3_3 conda-forge libwebp 1.2.2 h28dabe5_0 conda-forge libwebp-base 1.2.2 h0d85af4_1 conda-forge libxcb 1.13 h0d85af4_1004 conda-forge libzlib 1.2.11 h6c3fc93_1014 conda-forge llvm-openmp 14.0.3 ha654fa7_0 conda-forge lz4-c 1.9.3 he49afe7_1 conda-forge matplotlib 3.4.3 py38hecd8cb5_0 anaconda matplotlib-base 3.4.3 py38h0a11d32_0 anaconda munkres 1.1.4 pyh9f0ad1d_0 conda-forge ncurses 6.3 h96cf925_1 conda-forge numpy 1.20.3 py38h0fa1045_0 anaconda numpy-base 1.20.3 py38hbbe2e76_0 anaconda openblas 0.3.20 openmp_h5ad848b_0 conda-forge opencv-python 4.2.0.34 pypi_0 pypi openjpeg 2.4.0 h6e7aa92_1 conda-forge openssl 1.1.1n hca72f7f_0 anaconda packaging 21.3 pyhd8ed1ab_0 conda-forge pandas 1.2.4 py38hb2f4e1b_0 anaconda pathlib2 2.3.7.post1 py38h50d1736_1 conda-forge patsy 0.5.2 pyhd8ed1ab_0 conda-forge pillow 9.1.1 py38h21af888_0 conda-forge pip 22.1 pyhd8ed1ab_0 conda-forge pthread-stubs 0.4 hc929b4f_1001 conda-forge pycparser 2.21 pyhd8ed1ab_0 conda-forge pyopenssl 22.0.0 pyhd8ed1ab_0 conda-forge pyparsing 3.0.9 pyhd8ed1ab_0 conda-forge pypubsub 4.0.3 py_0 conda-forge pysocks 1.7.1 py38h50d1736_5 conda-forge python 3.8.13 h394c593_0_cpython conda-forge python-dateutil 2.8.2 pyhd8ed1ab_0 conda-forge python.app 1.4 py38h96a0964_0 conda-forge python_abi 3.8 2_cp38 conda-forge pytz 2022.1 pyhd8ed1ab_0 conda-forge pyyaml 6.0 py38hed1de0f_4 conda-forge readline 8.1 h05e3726_0 conda-forge requests 2.27.1 pyhd8ed1ab_0 conda-forge scikit-learn 0.22.2.post1 py38h3dc85bc_0 conda-forge scipy 1.6.1 py38h41e0fa8_0 conda-forge seaborn 0.11.2 hd8ed1ab_0 conda-forge seaborn-base 0.11.2 pyhd8ed1ab_0 conda-forge setuptools 62.3.1 py38h50d1736_0 conda-forge six 1.16.0 pyh6c4a22f_0 conda-forge sqlite 3.38.5 hd9f0692_0 conda-forge statsmodels 0.11.1 py38haf1e3a3_0 anaconda tk 8.6.12 h5dbffcc_0 conda-forge tornado 6.1 py38hed1de0f_3 conda-forge unicodedata2 14.0.0 py38hed1de0f_1 conda-forge urllib3 1.26.9 pyhd8ed1ab_0 conda-forge wheel 0.37.1 pyhd8ed1ab_0 conda-forge wxpython 4.1.0 py38haae4e1a_4 conda-forge xorg-libxau 1.0.9 h35c211d_0 conda-forge xorg-libxdmcp 1.1.3 h35c211d_0 conda-forge xz 5.2.5 haf1e3a3_1 conda-forge yaml 0.2.5 h0d85af4_2 conda-forge zlib 1.2.11 h6c3fc93_1014 conda-forge zstd 1.5.2 ha9df2e0_1 conda-forge

backports.lzma==0.0.14 brotlipy @ file:///Users/runner/miniforge3/conda-bld/brotlipy_1648854236790/work certifi==2021.10.8 cffi @ file:///Users/runner/miniforge3/conda-bld/cffi_1636046182160/work charset-normalizer @ file:///home/conda/feedstock_root/build_artifacts/charset-normalizer_1644853463426/work cryptography @ file:///Users/runner/miniforge3/conda-bld/cryptography_1649035280383/work cycler @ file:///home/conda/feedstock_root/build_artifacts/cycler_1635519461629/work fastdtw @ file:///Users/runner/miniforge3/conda-bld/fastdtw_1607633537454/work fonttools @ file:///Users/runner/miniforge3/conda-bld/fonttools_1651017780550/work idna @ file:///home/conda/feedstock_root/build_artifacts/idna_1642433548627/work joblib @ file:///home/conda/feedstock_root/build_artifacts/joblib_1633637554808/work kiwisolver @ file:///Users/runner/miniforge3/conda-bld/kiwisolver_1648854503795/work matplotlib @ file:///opt/concourse/worker/volumes/live/f670ab63-e220-495e-450b-14c9591f195b/volume/matplotlib-suite_1634667037960/work munkres==1.1.4 numpy @ file:///opt/concourse/worker/volumes/live/29c71c97-15d9-492d-6af0-6aff94b2b16c/volume/numpy_and_numpy_base_1626271793863/work opencv-python==4.2.0.34 packaging @ file:///home/conda/feedstock_root/build_artifacts/packaging_1637239678211/work pandas==1.2.4 pathlib2 @ file:///Users/runner/miniforge3/conda-bld/pathlib2_1649684195554/work patsy @ file:///home/conda/feedstock_root/build_artifacts/patsy_1632667180946/work Pillow @ file:///Users/runner/miniforge3/conda-bld/pillow_1652815216898/work pycparser @ file:///home/conda/feedstock_root/build_artifacts/pycparser_1636257122734/work pyOpenSSL @ file:///home/conda/feedstock_root/build_artifacts/pyopenssl_1643496850550/work pyparsing @ file:///home/conda/feedstock_root/build_artifacts/pyparsing_1652235407899/work Pypubsub==4.0.3 PySocks @ file:///Users/runner/miniforge3/conda-bld/pysocks_1648857369880/work python-dateutil @ file:///home/conda/feedstock_root/build_artifacts/python-dateutil_1626286286081/work pytz @ file:///home/conda/feedstock_root/build_artifacts/pytz_1647961439546/work PyYAML @ file:///Users/runner/miniforge3/conda-bld/pyyaml_1648757416758/work requests @ file:///home/conda/feedstock_root/build_artifacts/requests_1641580202195/work scikit-learn==0.22.2.post1 scipy @ file:///Users/runner/miniforge3/conda-bld/scipy_1615963791203/work seaborn @ file:///home/conda/feedstock_root/build_artifacts/seaborn-split_1629095986539/work six @ file:///home/conda/feedstock_root/build_artifacts/six_1620240208055/work statsmodels==0.11.1 tornado @ file:///Users/runner/miniforge3/conda-bld/tornado_1648827543297/work unicodedata2 @ file:///Users/runner/miniforge3/conda-bld/unicodedata2_1649111979354/work urllib3 @ file:///home/conda/feedstock_root/build_artifacts/urllib3_1647489083693/work wxPython==4.1.0 ~

sollan commented 2 years ago

Hi! I still couldn't replicate the error due to the text formatting. But I would advise to avoid Anaconda (and use pip or brew to install in a virtual environment instead), as we didn't publish the library on conda or test the requirements.txt in a conda environment. So there could be potential conflicts in the dependencies.

Meanwhile, perhaps this would help suppress the warning?

michaelru2000 commented 2 years ago

Hi again, I am having a lot of trouble trying to do the installation. Would you be able to give me a detailed set of instructions on how you did the installation in terminal?

sollan commented 2 years ago

Hi! It seems you are currently working with Mac, so I replicated the installation today on a Macbook with the following steps:

  1. Install Python version 3.8.5 from here. Just to make sure we have the same environment, this was the tried-and-true release I used for development, although other versions could also work.
  2. Go to the terminal.
  3. Make sure you are now using Python 3.8.5. You should see the correct Python version in the Python shell once you run python3, for example.
  4. If you don't have it already, install virtualenv: brew install virtualenv
  5. cd to the directory where you have downloaded / cloned the repository.
  6. Using the correct command for Python, as tested in step 3, make a virtual environment: python3 -m venv alma-env
  7. Activate the virtual environment: source ./alma-env/bin/activate
  8. Make sure you are in the root directory of the repository, run ls and you should see the requirements.txt file.
  9. If you don't have it already, install pip: curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py then python3 get-pip.py
  10. Download the required packages: pip install -r requirements.txt I did not get any error here.
  11. The program now opens successfully with python3 alma.py

Please let me know if this helps resolve the issue! For Linux environments, there is already a detailed tutorial at the Readme page.

michaelru2000 commented 2 years ago

Thank you so much! I got it working. I think the problem was with previous packages I had installed and uninstalled. Anyways, you have been an incredible help, thanks again.

mdbudde commented 1 year ago

For those looking to use conda on a Mac, this processes worked for me to eliminate the errors described above when installing and starting the program.

With anaconda already installed:

conda create --name alma
conda activate alma
conda install -c conda-forge python=3.8.5

in requirements.txt, change scikit-learn==0.22.2.post1 to scikit-learn>=0.22.2.post1

git clone https://github.com/sollan/alma.git
cd alma
pip install -r requirements.txt

conda install -c conda-forge wxPython

pip install -r requirements.txt

Start the program with

pythonw ./alma.py

I assume a few steps could be omitted by changing the dependancies, but this is what worked for me. The program starts with the gui, and although I haven't used it extensively, it eliminates the startup errors.