HEXRD / hexrd

A cross-platform, open-source library for the analysis of X-ray diffraction data.
Other
56 stars 25 forks source link

Installation via conda fails on Windows #532

Closed asteppke closed 1 year ago

asteppke commented 1 year ago

When trying to start hexrd/hexrdgui after following the installation path through conda the software cannot be started.

On Windows 11 I followed the manual and tried:

conda create -n hexrdgui
conda activate hexrdgui
conda install -c hexrd -c conda-forge python=3.10 hexrdgui

This runs without issues and generates the attached environment which looks fine:

hexrd                     0.9.2                   py310_0    hexrd
hexrdgui                  0.9.5           py310h61cd40d_0    hexrd
[...]
python                    3.10.11         h4de0772_0_cpython    conda-forge

Then starting the software either via hexrdgui, hexrdgui --help or hexrd does not work and it returns without error message to the command line:

(hexrdgui) C:\Users\Alexander>hexrdgui --help

(hexrdgui) C:\Users\Alexander>

Can you give me a hint how to diagnose this issue?

psavery commented 1 year ago

Yes, I just ran into this same issue yesterday, in fact. The “lxml” library version 4.9.1 is causing windows to crash silently when it is imported.

We depend on “lxml” because for some file formats, we use fabio, which installs it.

Can you try upgrading lxml to 4.9.2? That fixed it for me, and we are going to put that in as a requirement soon.

Run: ‘conda install -c conda-forge lxml==4.9.2’

Then try starting up the GUI again. Let me know how it goes.

We are about to come out with a new release in the next few days, which is going to include many new features. Feel free to try the prerelease, as it includes these already.

asteppke commented 1 year ago

Thanks @psavery for the instant reply!

I convinced conda to install lxml 4.9.2 (it then downgraded other packages slightly) and hexrd now starts successfully. I cannot run the test suite, that seems to require files that are not in the default install.

hexrdgui is still not happy with me unfortunately:

(hexrdgui) C:\Users\Alexander>hexrdgui
C:\tools\miniconda3\envs\hexrdgui\lib\site-packages\hexrd\unitcell.py:944: FutureWarning: In the future `np.bool` will be defined as the corresponding NumPy scalar.
  mask = np.ones(hkllist.shape[0], dtype=np.bool)
Unable to create a Python custom widget of type "ImageTabWidget".
Traceback (most recent call last):
  File "C:\tools\miniconda3\envs\hexrdgui\lib\site-packages\hexrd\ui\hexrd_config.py", line 385, in load_from_state
    setattr(self, name, value)
  File "C:\tools\miniconda3\envs\hexrdgui\lib\site-packages\hexrd\ui\hexrd_config.py", line 480, in _imported_default_materials
    self.load_default_material(x)
  File "C:\tools\miniconda3\envs\hexrdgui\lib\site-packages\hexrd\ui\hexrd_config.py", line 1418, in load_default_material
    materials[name] = Material(name, file_path)
  File "C:\tools\miniconda3\envs\hexrdgui\lib\site-packages\hexrd\material.py", line 205, in __init__
    self._newPdata()
  File "C:\tools\miniconda3\envs\hexrdgui\lib\site-packages\hexrd\material.py", line 278, in _newPdata
    hkls = self.unitcell.getHKLs(self._dmin.getVal('nm')).T
  File "C:\tools\miniconda3\envs\hexrdgui\lib\site-packages\hexrd\unitcell.py", line 1047, in getHKLs
    hkl = self.ChooseSymmetric(hkl_dsp, InversionSymmetry=True)
  File "C:\tools\miniconda3\envs\hexrdgui\lib\site-packages\hexrd\unitcell.py", line 944, in ChooseSymmetric
    mask = np.ones(hkllist.shape[0], dtype=np.bool)
  File "C:\tools\miniconda3\envs\hexrdgui\lib\site-packages\numpy\__init__.py", line 305, in __getattr__
    raise AttributeError(__former_attrs__[attr])
AttributeError: module 'numpy' has no attribute 'bool'.
`np.bool` was a deprecated alias for the builtin `bool`. To avoid this error in existing code, use `bool` by itself. Doing this will not modify any behavior and is safe. If you specifically wanted the numpy scalar type, use `np.bool_` here.
The aliases was originally deprecated in NumPy 1.20; for more details and guidance see the original release note at:
    https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations. Did you mean: 'bool_'?

This hints to an incompatibility with numpy (here conda installed 1.24.3).

As the released .zip works fine here I will wait for your new release and try again with a new conda environment from scratch then.

psavery commented 1 year ago

@asteppke Yeah, we fixed that issue recently too! It was caused by a recent change in numpy (and upgrading lxml might have required you to upgrade your numpy as well). Dependencies can be difficult!

Well, they should all be fixed in the new release in a few days. I'm glad the Windows ZIP is working fine - it used all of the latest dependency versions at the time it was built.

About the hexrd tests - yes, they require this repository, and you specify the path to it via the environment variable HEXRD_EXAMPLE_REPO_PATH (see our CI example here).

psavery commented 1 year ago

@asteppke The new release is on anaconda now! If you install in a fresh conda environment, it should install hexrd==0.9.3 and hexrdgui==0.9.6.

We will also have a ZIP file for Windows for the new release in the next day or so.

psavery commented 1 year ago

@asteppke sorry, I forgot to follow up with the release info! We did end up generating the packages for the release, and you can find them here! https://github.com/HEXRD/hexrdgui/releases/tag/0.9.6

Please let us know if you need anything else. Thank you!

asteppke commented 1 year ago

@psavery Works like a charm, thank you very much!