spirit-code / spirit

Atomistic Spin Simulation Framework
http://spirit-code.github.io
MIT License
117 stars 52 forks source link

Spirit.exe crash "Qt5charts.dll not found" #609

Closed Sid8899 closed 2 years ago

Sid8899 commented 2 years ago

Hi, I'm trying to compile Spirit on windows 11 and I get an error message when I launch spirit.exe, it says "Qt5Charts.dll not found" same other messages for Core, Widgets, GUI and OpenGL. Even if I adjusted Qt5 path in cmake. . I'm using cmake-gui(latest version); visual studio 2022 with latest msvc complier and windows SDK; and Qt 5.15.2 with qt-charts

For spirit python package, if I install it with pip it does not work.

Sincerly Mehdi

GPMueller commented 2 years ago

Hi, I'm trying to compile Spirit on windows 11 and I get an error message when I launch spirit.exe, it says "Qt5Charts.dll not found" same other messages for Core, Widgets, GUI and OpenGL. Even if I adjusted Qt5 path in cmake. I'm using cmake-gui(latest version); visual studio 2022 with latest msvc complier and windows SDK; and Qt 5.15.2 with qt-charts

Since you seem to have managed to build the executable, I assume you installed everything correctly, but overlooked this sentence in the docs:

Note that in order to build with Qt as a dependency on Windows, you may need to add path/to/qt/qtbase/bin to your PATH variable.

Once in the PATH, the dll's, which should be in the qtbase/bin folder, will be found.


For spirit python package, if I install it with pip it does not work.

Please be more precise - what did you do, what did you expect to happen and what happened instead?

Sid8899 commented 2 years ago

Thanks adding Qt to windows path solved the issue, I added it to the system path with restart of the laptop. Since Spirit is built in Program Files, I added the full rights for my account user so Spirit can write output files without running in admin.

For python API, I use "pip install spirit" but I get this error when I run a code : Could not find module 'C:\Users\Username\AppData\Local\Programs\Python\Python310\Lib\site-packages\spirit\Spirit.dll' (or one of its dependencies). Try using the full path with constructor syntax.

I tried to follow the doc by using " pip install -e . --user" in core/python I get this :

Obtaining file:///C:/Spirit/core/python
  Preparing metadata (setup.py) ... done
Requirement already satisfied: numpy in c:\users\mehdi\appdata\local\programs\python\python310\lib\site-packages (from spirit==2.1.1) (1.22.1)
Installing collected packages: spirit
  Running setup.py develop for spirit
    error: subprocess-exited-with-error

    × python setup.py develop did not run successfully.
    │ exit code: 1
    ╰─> [38 lines of output]
        running develop
        C:\Users\Mehdi\AppData\Local\Programs\Python\Python310\lib\site-packages\setuptools\command\easy_install.py:156: EasyInstallDeprecationWarning: easy_install command is deprecated. Use build and pip and other standards-based tools.
          warnings.warn(
        Traceback (most recent call last):
          File "C:\Users\Mehdi\AppData\Local\Programs\Python\Python310\lib\site-packages\setuptools\_distutils\util.py", line 258, in subst_vars
            return _subst_compat(s).format_map(lookup)
        KeyError: 'py_version_nodot_plat'

        During handling of the above exception, another exception occurred:
        Traceback (most recent call last):
          File "<string>", line 2, in <module>
          File "<pip-setuptools-caller>", line 34, in <module>
          File "C:\Spirit\core\python\setup.py", line 121, in <module>
            setup(
          File "C:\Users\Mehdi\AppData\Local\Programs\Python\Python310\lib\site-packages\setuptools\__init__.py", line 155, in setup
            return distutils.core.setup(**attrs)
          File "C:\Users\Mehdi\AppData\Local\Programs\Python\Python310\lib\site-packages\setuptools\_distutils\core.py", line 148, in setup
            return run_commands(dist)
          File "C:\Users\Mehdi\AppData\Local\Programs\Python\Python310\lib\site-packages\setuptools\_distutils\core.py", line 163, in run_commands
            dist.run_commands()
          File "C:\Users\Mehdi\AppData\Local\Programs\Python\Python310\lib\site-packages\setuptools\_distutils\dist.py", line 967, in run_commands
            self.run_command(cmd)
          File "C:\Users\Mehdi\AppData\Local\Programs\Python\Python310\lib\site-packages\setuptools\_distutils\dist.py", line 985, in run_command
            cmd_obj.ensure_finalized()
          File "C:\Users\Mehdi\AppData\Local\Programs\Python\Python310\lib\site-packages\setuptools\_distutils\cmd.py", line 107, in ensure_finalized
            self.finalize_options()
          File "C:\Users\Mehdi\AppData\Local\Programs\Python\Python310\lib\site-packages\setuptools\command\develop.py", line 52, in finalize_options
            easy_install.finalize_options(self)
          File "C:\Users\Mehdi\AppData\Local\Programs\Python\Python310\lib\site-packages\setuptools\command\easy_install.py", line 273, in finalize_options
            self.expand_dirs()
          File "C:\Users\Mehdi\AppData\Local\Programs\Python\Python310\lib\site-packages\setuptools\command\easy_install.py", line 408, in expand_dirs            self._expand_attrs(dirs)
          File "C:\Users\Mehdi\AppData\Local\Programs\Python\Python310\lib\site-packages\setuptools\command\easy_install.py", line 390, in _expand_attrs
            val = subst_vars(val, self.config_vars)
          File "C:\Users\Mehdi\AppData\Local\Programs\Python\Python310\lib\site-packages\setuptools\_distutils\util.py", line 260, in subst_vars
            raise ValueError(f"invalid variable {var}")
        ValueError: invalid variable 'py_version_nodot_plat'
        [end of output]

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

× python setup.py develop did not run successfully.
│ exit code: 1
╰─> [38 lines of output]
    running develop
    C:\Users\Mehdi\AppData\Local\Programs\Python\Python310\lib\site-packages\setuptools\command\easy_install.py:156: EasyInstallDeprecationWarning: easy_install command is deprecated. Use build and pip and other standards-based tools.
      warnings.warn(
    Traceback (most recent call last):
      File "C:\Users\Mehdi\AppData\Local\Programs\Python\Python310\lib\site-packages\setuptools\_distutils\util.py", line 258, in subst_vars
        return _subst_compat(s).format_map(lookup)
    KeyError: 'py_version_nodot_plat'

    During handling of the above exception, another exception occurred:

    Traceback (most recent call last):
      File "<string>", line 2, in <module>
      File "<pip-setuptools-caller>", line 34, in <module>
      File "C:\Spirit\core\python\setup.py", line 121, in <module>
        setup(
      File "C:\Users\Mehdi\AppData\Local\Programs\Python\Python310\lib\site-packages\setuptools\__init__.py", line 155, in setup
        return distutils.core.setup(**attrs)
      File "C:\Users\Mehdi\AppData\Local\Programs\Python\Python310\lib\site-packages\setuptools\_distutils\core.py", line 148, in setup
        return run_commands(dist)
      File "C:\Users\Mehdi\AppData\Local\Programs\Python\Python310\lib\site-packages\setuptools\_distutils\core.py", line 163, in run_commands
        dist.run_commands()
      File "C:\Users\Mehdi\AppData\Local\Programs\Python\Python310\lib\site-packages\setuptools\_distutils\dist.py", line 967, in run_commands
        self.run_command(cmd)
      File "C:\Users\Mehdi\AppData\Local\Programs\Python\Python310\lib\site-packages\setuptools\_distutils\dist.py", line 985, in run_command
        cmd_obj.ensure_finalized()
      File "C:\Users\Mehdi\AppData\Local\Programs\Python\Python310\lib\site-packages\setuptools\_distutils\cmd.py", line 107, in ensure_finalized
        self.finalize_options()
      File "C:\Users\Mehdi\AppData\Local\Programs\Python\Python310\lib\site-packages\setuptools\command\develop.py", line 52, in finalize_options
        easy_install.finalize_options(self)
      File "C:\Users\Mehdi\AppData\Local\Programs\Python\Python310\lib\site-packages\setuptools\command\easy_install.py", line 273, in finalize_options
        self.expand_dirs()
      File "C:\Users\Mehdi\AppData\Local\Programs\Python\Python310\lib\site-packages\setuptools\command\easy_install.py", line 408, in expand_dirs
        self._expand_attrs(dirs)
      File "C:\Users\Mehdi\AppData\Local\Programs\Python\Python310\lib\site-packages\setuptools\command\easy_install.py", line 390, in _expand_attrs
        val = subst_vars(val, self.config_vars)
      File "C:\Users\Mehdi\AppData\Local\Programs\Python\Python310\lib\site-packages\setuptools\_distutils\util.py", line 260, in subst_vars
        raise ValueError(f"invalid variable {var}")
    ValueError: invalid variable 'py_version_nodot_plat'
    [end of output]

note: This error originates from a subprocess, and is likely not a problem with pip.
GPMueller commented 2 years ago

Sorry, but I'm afraid I have no idea why you're getting that error...

Sid8899 commented 2 years ago

Hi I get over it, so I installed python API with "pip install spirit", then I modified the line 22 of the file spiritlib.py present in "C:\Users\Mehdi\AppData\Local\Programs\Python\Python310\Lib\site-packages\spirit\spiritlib.py". I replaced spirit_py_dir by 'C:/Program Files/spirit/bin' it should not be the best way to resolve this but it's work

GPMueller commented 2 years ago

Oh indeed, the Python-package is apparently incomplete, the dll is missing - I hadn't tried installing from PyPI on Windows for quite a while, but I know it was working at some point.

@MSallermann I think I found the bug. The CMakeLists.txt contains ${META_PROJECT_NAME}, which resolves to Spirit and on Windows leads to Spirit.dll (on Linux and macOS, the shared library prefix is lib, giving libSpirit.so and libSpirit.dylib): https://github.com/spirit-code/spirit/blob/14ed7782bd23f4828bf23ab8136ae31a21037bb3/core/CMakeLists.txt#L555-L558 but the setup.py contains libSpirit.dll instead of Spirit.dll: https://github.com/spirit-code/spirit/blob/14ed7782bd23f4828bf23ab8136ae31a21037bb3/core/python/setup.py#L138 so the package uploaded to PyPI won't contain the dll.

MSallermann commented 2 years ago

Thanks! Should be fixed with 6b0ae0bbffbe9dde28ceb4d3583315f10f0b294d.