WISDEM / RAFT

A frequency-domain dynamics model for floating wind turbines
https://openraft.readthedocs.io
Apache License 2.0
40 stars 21 forks source link

Example not working: Error: No module named 'pyhams' #20

Closed HansiLeMann closed 1 year ago

HansiLeMann commented 1 year ago

I have recently rebooted my PC and reinstalled RAFT. However, the installation seems to be unsuccessful as when I run the example_from_yaml.py i get the following error:

cd RAFT cd examples (raft-env) PS C:\Users\hfleh\RAFT\examples> python example_from_yaml.py Traceback (most recent call last): File "C:\Users\hfleh\RAFT\examples\example_from_yaml.py", line 6, in import raft File "c:\users\hfleh\raft\raft__init__.py", line 3, in import raft.raft_model as model File "c:\users\hfleh\raft\raft\raft_model.py", line 15, in import raft.raft_fowt as fowt File "c:\users\hfleh\raft\raft\raft_fowt.py", line 7, in import pyhams.pyhams as ph ModuleNotFoundError: No module named 'pyhams' (raft-env) PS C:\Users\hfleh\RAFT\examples>`

I have cloned and setup all relevant repositories: WISDEM, MoorPy, PyHAMS, RAFT. Can you help me?

gbarter commented 1 year ago

The pyHAMS installation did not succeed. There should be a setup.log and a compile.log file in the meson_build directory in your pyHAMS directory. Can you post those?

HansiLeMann commented 1 year ago

Thank you for the very fast response!

I got the pyHAMS installation working, but now WISDEM is failing. Seems to be an installation error again.

When I install WISDEM the output is as follows:

(raft-env) PS C:\Users\hfleh\WISDEM> python setup.py develop
>>
>>
C:\Users\hfleh\WISDEM\setup.py:7: DeprecationWarning:

  `numpy.distutils` is deprecated since NumPy 1.23.0, as a result
  of the deprecation of `distutils` itself. It will be removed for
  Python >= 3.12. For older Python versions it will remain present.
  It is recommended to use `setuptools < 60.0` for those Python versions.
  For more details, see:
    https://numpy.org/devdocs/reference/distutils_status_migration.html

  from numpy.distutils.core import Extension, setup
running develop
C:\Users\hfleh\anaconda3\envs\raft-env\lib\site-packages\setuptools\command\easy_install.py:144: EasyInstallDeprecationWarning: easy_install command is deprecated. Use build and pip and other standards-based tools.
  warnings.warn(
C:\Users\hfleh\anaconda3\envs\raft-env\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_scripts
running egg_info
running build_src
INFO: build_src
INFO: building extension "wisdem.ccblade._bem" sources
INFO: f2py options: []
INFO:   adding 'build\src.win-amd64-3.9\build\src.win-amd64-3.9\wisdem\ccblade\fortranobject.c' to sources.
INFO:   adding 'build\src.win-amd64-3.9\build\src.win-amd64-3.9\wisdem\ccblade' to include_dirs.
INFO:   adding 'build\src.win-amd64-3.9\wisdem\ccblade\_bem-f2pywrappers.f' to sources.
INFO: building extension "wisdem.pyframe3dd._pyframe3dd" sources
INFO: building extension "wisdem.rotorse._precomp" sources
INFO: f2py options: []
INFO: f2py:> build\src.win-amd64-3.9\wisdem\rotorse\_precompmodule.c
Reading fortran codes...
Traceback (most recent call last):
  File "C:\Users\hfleh\anaconda3\envs\raft-env\lib\site-packages\numpy\f2py\crackfortran.py", line 393, in readfortrancode
    l = fin.readline()
  File "C:\Users\hfleh\anaconda3\envs\raft-env\lib\fileinput.py", line 305, in readline
    line = self._readline()
  File "C:\Users\hfleh\anaconda3\envs\raft-env\lib\fileinput.py", line 369, in _readline
    return self._readline()
  File "C:\Users\hfleh\anaconda3\envs\raft-env\lib\encodings\ascii.py", line 26, in decode
    return codecs.ascii_decode(input, self.errors)[0]
UnicodeDecodeError: 'ascii' codec can't decode byte 0xce in position 6993: ordinal not in range(128)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\hfleh\WISDEM\setup.py", line 29, in <module>
    setup(
  File "C:\Users\hfleh\anaconda3\envs\raft-env\lib\site-packages\numpy\distutils\core.py", line 169, in setup
    return old_setup(**new_attr)
[...]
 File "C:\Users\hfleh\anaconda3\envs\raft-env\lib\site-packages\numpy\f2py\crackfortran.py", line 395, in readfortrancode
    raise Exception(
Exception: readfortrancode: reading wisdem\rotorse\PreCompPy.f90#0 failed with
'ascii' codec can't decode byte 0xce in position 6993: ordinal not in range(128).
It is likely that installing chardet package will help f2py determine the input file encoding correctly.

When I run the example_from_yaml I get the following error:

(raft-env) PS C:\Users\hfleh\RAFT\examples> python example_from_yaml.py
Traceback (most recent call last):
  File "C:\Users\hfleh\RAFT\examples\example_from_yaml.py", line 6, in <module>
    import raft
  File "c:\users\hfleh\raft\raft\__init__.py", line 3, in <module>
    import raft.raft_model as model
  File "c:\users\hfleh\raft\raft\raft_model.py", line 15, in <module>
    import raft.raft_fowt  as fowt
  File "c:\users\hfleh\raft\raft\raft_fowt.py", line 11, in <module>
    from raft.raft_rotor import Rotor
  File "c:\users\hfleh\raft\raft\raft_rotor.py", line 19, in <module>
    from wisdem.ccblade.ccblade import CCBlade, CCAirfoil
ModuleNotFoundError: No module named 'wisdem'
(raft-env) PS C:\Users\hfleh\RAFT\examples>

Do you have any recommendations of what to do?

gbarter commented 1 year ago

Yes, I just fixed this the past few days. There were changes in the 3rd party libraries that made them a little less robust. If you do:

git checkout develop
git pull
python setup.py develop

In your WISDEM directory, things should be working.

If you instead installed WISDEM as a conda package, then I can push an update there, but haven't done so yet.

HansiLeMann commented 1 year ago

Thank you! I got WISDEM successfully downloaded, but now errors, when running the example_from_yaml:

(raft-env) PS C:\Users\hfleh> pip install marmot-agents
Requirement already satisfied: marmot-agents in c:\users\hfleh\anaconda3\envs\raft-env\lib\site-packages (0.2.5)
Requirement already satisfied: numpy in c:\users\hfleh\anaconda3\envs\raft-env\lib\site-packages (from marmot-agents) (1.24.0)
(raft-env) PS C:\Users\hfleh\RAFT\examples> pip install simpy
Requirement already satisfied: simpy in c:\users\hfleh\anaconda3\envs\raft-env\lib\site-packages (4.0.1)
(raft-env) PS C:\Users\hfleh\RAFT\examples> python example_from_yaml.py
WARNING: Be sure to pip install simpy and marmot-agents for offshore BOS runs
Traceback (most recent call last):
  File "C:\Users\hfleh\RAFT\examples\example_from_yaml.py", line 17, in <module>
    model.analyzeUnloaded()
  File "c:\users\hfleh\raft\raft\raft_model.py", line 135, in analyzeUnloaded
    fowt.calcStatics()
  File "c:\users\hfleh\raft\raft\raft_fowt.py", line 286, in calcStatics
    if np.float(pballast[j]) == np.float(self.pb[i]):   # but only if the index of the ballast mass (density) matches the value of pb
  File "C:\Users\hfleh\anaconda3\envs\raft-env\lib\site-packages\numpy\__init__.py", line 284, in __getattr__
    raise AttributeError("module {!r} has no attribute "
AttributeError: module 'numpy' has no attribute 'float'

I have made sure to install the necessary libraries. Do you have any suggestions?

gbarter commented 1 year ago

Since this is a bug in the core RAFT code, I will defer to @mattEhall here before making any code edits.

vbenifla commented 1 year ago

Hello,

I believe this is due to numpy's latest release 1.24. For now one could use an older version of numpy, I downgraded it using: conda install -c conda-forge numpy=1.23

And now the Raft example from yaml works fine. Hope it helps !

HansiLeMann commented 1 year ago

Thank you! It's working.

mattEhall commented 1 year ago

Thank you all, for the problems and solutions. I've just pushed a small fix for that last bug (now using float() instead of np.float()). There is also has a small update to allow using CCBlade without the full WISDEM installation (as discussed in https://github.com/WISDEM/RAFT/issues/17).

gbarter commented 1 year ago

I submitted some robustness improvements in the install of both pyHAMS and WISDEM. If the primary purpose is to use RAFT, I would suggest simply doing conda install wisdem to satisfy dependencies. The alternative is to go through the WISDEM installation steps outlined at its Github site.