xraypy / xraylarch

Larch: Applications and Python Library for Data Analysis of X-ray Absorption Spectroscopy (XAS, XANES, XAFS, EXAFS), X-ray Fluorescence (XRF) Spectroscopy and Imaging, and more.
https://xraypy.github.io/xraylarch
Other
127 stars 62 forks source link

error: Running setup.py install for cchardet did not run successfully #419

Closed maschined closed 1 year ago

maschined commented 1 year ago

Hi,

I tried to install Larch in a xraylarch environment in the existing Anaconda installation on my Windows 10 PC. I ran the following, as suggested: conda create -y --name xraylarch python=>3.9.10 conda activate xraylarch conda install -y "numpy=>1.20" "scipy=>1.6" "matplotlib=>3.0" scikit-learn pandas conda install -y -c conda-forge wxpython pymatgen tomopy pycifrw pip install xraylarch

However, the last instance - the actual installation of larch - didn't work: I get the following message. ###################################################################################################### Building wheels for collected packages: cchardet Building wheel for cchardet (setup.py) ... error error: subprocess-exited-with-error

× python setup.py bdist_wheel did not run successfully. │ exit code: 1 ╰─> [11 lines of output] running bdist_wheel running build running build_py creating build creating build\lib.win-amd64-cpython-310 creating build\lib.win-amd64-cpython-310\cchardet copying src\cchardet\version.py -> build\lib.win-amd64-cpython-310\cchardet copying src\cchardet__init__.py -> build\lib.win-amd64-cpython-310\cchardet running build_ext building 'cchardet._cchardet' extension error: Microsoft Visual C++ 14.0 or greater is required. Get it with "Microsoft C++ Build Tools": https://visualstudio.microsoft.com/visual-cpp-build-tools/ [end of output]

note: This error originates from a subprocess, and is likely not a problem with pip. ERROR: Failed building wheel for cchardet Running setup.py clean for cchardet Failed to build cchardet Installing collected packages: cchardet, tomli, termcolor, pyshortcuts, psutil, pluggy, iniconfig, h5py, greenlet, fabio, exceptiongroup, attrs, asteval, sqlalchemy, silx, pytest, peakutils, numdifftools, lmfit, hdf5plugin, xraydb, pyfai, xraylarch Running setup.py install for cchardet ... error error: subprocess-exited-with-error

× Running setup.py install for cchardet did not run successfully. │ exit code: 1 ╰─> [13 lines of output] running install C:\Users\Sergiu\anaconda3\envs\xraylarch\lib\site-packages\setuptools\command\install.py:34: SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools. warnings.warn( running build running build_py creating build creating build\lib.win-amd64-cpython-310 creating build\lib.win-amd64-cpython-310\cchardet copying src\cchardet\version.py -> build\lib.win-amd64-cpython-310\cchardet copying src\cchardet__init__.py -> build\lib.win-amd64-cpython-310\cchardet running build_ext building 'cchardet._cchardet' extension error: Microsoft Visual C++ 14.0 or greater is required. Get it with "Microsoft C++ Build Tools": https://visualstudio.microsoft.com/visual-cpp-build-tools/ [end of output]

note: This error originates from a subprocess, and is likely not a problem with pip. error: legacy-install-failure

× Encountered error while trying to install package. ╰─> cchardet

note: This is an issue with the package mentioned above, not pip. hint: See above for output from the failure. ######################################################################################################

As suggested in this message, I installed "Microsoft C++ Build Tools": from https://visualstudio.microsoft.com/visual-cpp-build-tools/ The installed version is 17.4.4. I rebooted the PC. However, this error message still shows up when i try to install larch.

newville commented 1 year ago

@maschined Sorry for the trouble. I should have seen this coming (cchardet is kind of a new dependency for us, but it appears to be an abandoned project) and dealt with this earlier.

As an immediate workaround, I think you should be able to do (but I have not tested myself with Py 3.10 on Windows):

    conda install -c conda-forge cchardet
    pip install xraylarch

I have what I think is a more permanent solution to not use cchardet at all (and charset_normalizer instead) in the works. I hope to push that to the development version later today, but I'm not quite ready to make a release immediately.

maschined commented 1 year ago

@newville Thanks! The workaround works, I can run XAS viewer now.

maurov commented 1 year ago

@newville do you confirm charset-normalizer fully replaces cchardet dependency? I would like to update the documentation to close this issue plus #422

newville commented 1 year ago

@maurov Yes. The master branch now only uses charset-normalizer: it is a firm requirement and neither chardet nor cchardet are even looked for as options.

maurov commented 1 year ago

Ok, thanks. I close the issue then.