Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PyFMI 2.16.2 - problem with conda-forge installation #287

Closed
janpeter19 opened this issue Jan 25, 2025 · 14 comments
Closed

PyFMI 2.16.2 - problem with conda-forge installation #287

janpeter19 opened this issue Jan 25, 2025 · 14 comments
Assignees
Labels
installation-issue Issues related to installation of PyFMI

Comments

@janpeter19
Copy link

Hi,

In install PyFMI 2.16.2 using conda from conda-forge into Ubuntu 22.04 LTS and it does not wok. (I use Python 3.10.16 and Numpy 2.2.2 and Assimulo 3.6.0).

The problem is that pyfmi installation seems to work.

But when I do
from pyfmi import load_fmu
Then error message:
ModuleNotFoundError: No module named 'pyfmi.fmi'

If I check installation with
!conda list
or
!pip show pyfmi
it is there

Further it seems also not possible to now use the earlier PyFMI version 2.16.1

Here is perhaps some similarity (but also differences) with case #236 but not sure at all. What I do see is that here is a recent change to use Assimulo 3.6.0 that may have created my problems. But not sure at all.

Would be good to know if you still recommend to stay with Python 3.10 or I can use 3.11 or preferably 3.12. FMPy I run with Python 3.12 and would be good to have the same.

Jan Peter

PS. Test cases you have here https://github.com/janpeter19

@janpeter19 janpeter19 added the bug Issue or PR covers a bug. label Jan 25, 2025
@modelonrobinandersson modelonrobinandersson self-assigned this Jan 27, 2025
@modelonrobinandersson
Copy link
Member

Hi @janpeter19. It seems strange that you are seeing that error, it makes me believe something is wrong with the compiled Cython-files, or at least in the sense it is not compatible with your environment.

  • What version of GCC exists in your environment?

Regarding Python 3.10/3.11 or 3.12, I believe any should be OK to use. You can see the from the suffixes that all of those Python versions are supported: https://anaconda.org/conda-forge/pyfmi/files

@janpeter19
Copy link
Author

janpeter19 commented Jan 27, 2025

Hi @modelonrobinandersson. The FMUs are made in OpenModelica in Ubuntu 22.04 LTS with gcc 11.4.0.
Then the FMUs are used in Google Colab's virtual machine also with Ubuntu 22.04 LTS and here is also gcc 11.4.0,
although gcc is not used here, what I understand.

A related problem (perhaps) that I have lived with (for a long time) also with PyFMI 2.16.1, is that I have got warnings related to Assimulo and numerical algorithms that after all do not have any impact on the results, what I can see. Still an indiction of something not ok. Screenshot enclosed.

Image

@modelonrobinandersson
Copy link
Member

Hi @jschueller, is this something you have seen before and perhaps can share some guidance on?

@jschueller
Copy link
Contributor

it works fine for me from a clean miniforge install

@modelonrobinandersson
Copy link
Member

Hi @janpeter19 could you share what commando you use to install? Based on jschuellers comment above it seems to be working fine. I also wonder if you try to uninstall assimulo and pyfmi (or simply create a new virtual environment and attempt to install both pyfmi and assimulo there), do you still see the same issues?

@janpeter19
Copy link
Author

Hi @modelonrobinandersson. You have the script on Github here as a Google Colab notebook.
https://colab.research.google.com/github/janpeter19/BPL_TEST2_Batch/blob/main/BPL_TEST2_Batch_colab.ipynb

From your web-browser (and you need a gmail-adress) you can run the script using the virtual machine associated to you gmail-account. You just under heading "Runtime" choose "Run all" and you will see step by step what the commands are and what is happening. In cell #9 you get an error message that load_fmu cannot be imported since "pyfmi.fmi" cannot be found.

I just checked it again and it still does not work!

I have got the comment last year that I could try miniforge, but I am not convinced. After all I have used miniconda and conda-forge many years and the alternative for me is the package FMPy and that works just fine with miniconda and conda-forge.

So please try!

@jschueller
Copy link
Contributor

jschueller commented Feb 5, 2025

your script seems to be mixing packages from the "defaults" repo as well as conda-forge, this is not supported see:
https://conda-forge.org/docs/user/tipsandtricks/#why-does-that-happen
either use miniforge or set conda-forge as the top-priority repo

@janpeter19
Copy link
Author

janpeter19 commented Feb 5, 2025

@jschueller
I read the link and put in the line

!conda config --set channel_priority strict

Then the installation takes very, very long time

I would appreciate a bit more detailed help. Thank you.

@janpeter19
Copy link
Author

@jschueller
I upgraded Python to 3.12.8 and Conda to 24.11.1 (although here is also 25.1.0)

But I get the same error as before: No module named 'pyfmi.fmi'

The updated script you find here:
https://colab.research.google.com/github/janpeter19/BPL_TEST2_Batch/blob/main/BPL_TEST2_Batch_colab.ipynb

I would appreciate a bit more detailed help. Thank you!

@jschueller
Copy link
Contributor

Please try using miniforge

@modelonrobinandersson modelonrobinandersson added installation-issue Issues related to installation of PyFMI and removed bug Issue or PR covers a bug. labels Feb 5, 2025
@modelonrobinandersson
Copy link
Member

Hi @janpeter19 I see that you first use Python 3.12, and, after you run !conda update -n base -c defaults conda --yes I see that Python 3.10 is now installed, as from the output from conda:

python                                  3.10.9-h7a1cb2a_0 --> 3.10.16-he870216_1 

and also !python --version shows 3.10.16, is this intended? I am curious if that is causing the issues you are seeing because on your system path you now have 3.12 but your conda seems to default to 3.10.

In general when you see error ModuleNotFoundError: No module named 'pyfmi.fmi' it implies that something fishy is going on with your environment, since this indicates that the compiled Cython file fmi.<metadata depending platform and Python>.pyd is not found for your specific Python environment.

@janpeter19
Copy link
Author

Hi @modelonrobinandersson.
I see the misstake now. The TEST2_Batch example is updated and I will update all the other examples soon.
Of course the installed Python in the VM is Python 3.11.11 now and therefore Minconda3 for that version should be installed and nothing else. If I would like to have Python 3.12 environment I can make that as a conda environment and install PyFMI there and activate that environment. But I do not badly need 3.12 so I stay with 3.11 to shorten the setup-time.

I also note that PyFMI is updated to 2.16.3 that may, or may not have any impact here.

@modelonrobinandersson
Copy link
Member

modelonrobinandersson commented Feb 6, 2025

Hi @janpeter19, glad to hear it is working.
Just a general advice is that when you have multiple versions of Python installed to be extra cautious when installing packages. There are many ways to run into environment related issues and in particular when you are combining this with compiled cython files since the error handling from Python is not always the best.

I am closing this issue now but if you feel like it is not resolved feel free to open it again.

@janpeter19
Copy link
Author

You can close it. The error text in my second note above, I may come back to in a separate question. Can live with it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
installation-issue Issues related to installation of PyFMI
Projects
None yet
Development

No branches or pull requests

3 participants