blueCFD / Core

Coordination repository for the blueCFD-Core: Issue tracking, Wiki, project webpage and miscellaneous scripts
http://bluecfd.github.io/Core
53 stars 10 forks source link

Right way of installation of a Python package (numpy)? #128

Closed MarineAiry closed 4 years ago

MarineAiry commented 5 years ago

Dear Bruno,

I am so thankful for everything you share about blueCFD, allowing me to learn so much more. You don't know me, I am a newbie of blueCFD, and, if possible, I would ask you a question related to the right way of installation of a Python package (numpy) as I am trying to evaluate a resistance value for a ship model and so to ultimate my study.

Thank you for taking time out of your day by reading this message.

Kind regards,

Berin

wyldckat commented 5 years ago

Greetings @MarineAiry:

~For Python 2~ For searching for packages:

pacman -Ss pip
pacman -Ss numpy

For Python 3:

pacman -S mingw64/mingw-w64-x86_64-python3-pip
pacman -S  mingw64/mingw-w64-x86_64-python3-numpy

This is because MSys2 is what we use in blueCFD-Core to manage the packages needed for running inside and outside the terminal.

I'll make a note to add this to the FAQ...

MarineAiry commented 5 years ago

Thank you so much for your prompt response. I have done the operations as you mentioned before, but unfortunately it follows that I still don't have numpy installed. The blueCFD shell gives back the following error:

$ python3 averageForces.py Traceback (most recent call last): File "D:/PROGRAMMI/blueCFD-Core-2017/msys64/mingw64/lib/python3.6/site-packages\numpy\core__init__.py", line 40, in from . import multiarray File "D:/PROGRAMMI/blueCFD-Core-2017/msys64/mingw64/lib/python3.6/site-packages\numpy\core\multiarray.py", line 12, in from . import overrides File "D:/PROGRAMMI/blueCFD-Core-2017/msys64/mingw64/lib/python3.6/site-packages\numpy\core\overrides.py", line 6, in from numpy.core._multiarray_umath import ( ModuleNotFoundError: No module named 'numpy.core._multiarray_umath'

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "averageForces.py", line 4, in import numpy as np File "D:/PROGRAMMI/blueCFD-Core-2017/msys64/mingw64/lib/python3.6/site-packages\numpy__init.py", line 142, in from . import core File "D:/PROGRAMMI/blueCFD-Core-2017/msys64/mingw64/lib/python3.6/site-packages\numpy\core\init__.py", line 71, in raise ImportError(msg) ImportError:

wyldckat commented 5 years ago

According to this report: https://github.com/numpy/numpy/issues/11871 - the problem is that the numpy version provided by MSys2 is older than 1.16.0. More specifically, the package provided with MSys2 that comes with blueCFD-Core 2017-2 seems to be mingw-w64-x86_64-python3-numpy-1.13.0-1.

So first update the pacman repository:

pacman -Syy

Then (re)install/update numpy for Python 3:

pacman -S  mingw64/mingw-w64-x86_64-python3-numpy

Mmm.... weird, the import numpy command fails in the python3 shell ... OK, let's also (re)install/update Python 3:

pacman -S mingw64/mingw-w64-x86_64-python3

rm /mingw64/bin/python-config /mingw64/bin/python.exe
pacman -S mingw64/mingw-w64-x86_64-python3

The rm command line should only be used if you get this error message:

error: failed to commit transaction (conflicting files)
mingw-w64-x86_64-python3: /mingw64/bin/python-config exists in filesystem
mingw-w64-x86_64-python3: /mingw64/bin/python.exe exists in filesystem
Errors occurred, no packages were upgraded.

Might as well update pip too:

pacman -S mingw64/mingw-w64-x86_64-python3-pip

OK... I finally have gotten a message similar to yours, ending in:

Original error was: DLL load failed: The specified module could not be found.

I'm doing a new installation of MSys2, to try and figure out if it's a package update problem or if it's really MSys2 that has an incomplete build of numpy for Python 3...

wyldckat commented 5 years ago

I've confirmed that with a clean and up-to-date installation of MSys2, numpy will work as intended.

There are two possible choices you can make at this point:

  1. Either you install a separate up-to-date installation of MSys2, by following the instructions given here: http://www.msys2.org/

  2. Or upgrade the MSys2 installation that comes with blueCFD-Core 2017-2, by following the steps 5 and 6 from that page, which will update and upgrade it.

    • However, keep in mind that I have not tested this and I'm not sure what the repercussions will be; at the very least, you might still be able to run the OpenFOAM installation that is provided with blueCFD-Core, but you might no longer be able to compile/build custom applications based on OpenFOAM, due to the GCC installation being upgraded.
MarineAiry commented 5 years ago

Thanks you for being such a great support for me.

I am trying to follow your instructions. Still having trouble with that. I hope that by uninstalling/installing the latest version of blueCFD things will become clearer. For sure I will update you.

Thanks you again for helping me !!

MarineAiry commented 5 years ago

I re-installed blueCFD -Core 2017-2 , then I followed the steps 5 and 6 from http://www.msys2.org/ pacman -Syu pacman -Su After that: pacman -Ss numpy and then, as suggested in this thread: pacman -S mingw64/mingw-w64-x86_64-python3-numpy Finally I wrote: python3 averageForces.py but unfortunately it doesn't work, because I got the error as below: Error message: $ python3 averageForces.py Traceback (most recent call last): File "averageForces.py", line 5, in <module> import matplotlib.pyplot as plt ModuleNotFoundError: No module named 'matplotlib'

Numpy/Python version information: numpy-1.16.4-1 python 3.7.4 Windows 10 no pip installed

I was thinking of installing pip also, and so write python -mpip install -U matplotlib but I am not sure it will solve the issue. Any suggestion on how to solve that ?

Thanks again

wyldckat commented 5 years ago

Sorry for the late reply, but I've been having some limitations on the time I can use to work on this.

So here are the commands I've used, after the 2 commands from steps 5 and 6 on msys2's site:

pacman -S mingw64/mingw-w64-x86_64-python3
pacman -S mingw64/mingw-w64-x86_64-python3-numpy
pacman -S mingw64/mingw-w64-x86_64-python3-matplotlib

The last command is what was missing from your steps. This is because the error message was for this line:

import matplotlib.pyplot as plt

And looking for the module matplotlib:

pacman -Ss matplotlib

gave me that package among the list of possible packages.

MarineAiry commented 5 years ago

@wyldckat Thank you very much. I just wrote pacman -S mingw64/mingw-w64-x86_64-python3-matplotlib And now matloplib is included and $ python3 averageForces.py is working fine.

I feel so happy for that, Thank you much again !!:)

wyldckat commented 5 years ago

You're welcome! I'm reopening this, so that I don't forget that I need to add this to the FAQ page.

MarineAiry commented 5 years ago

@wyldckat All right. Again, thank you a lot :)