CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Community Contributions (https://www.cfd-online.com/Forums/openfoam-community-contributions/)
-   -   [PyFoam] on Ubuntu 16.04 (https://www.cfd-online.com/Forums/openfoam-community-contributions/174566-ubuntu-16-04-a.html)

Danubi July 14, 2016 11:20

on Ubuntu 16.04
 
Hi all,

I'm having troubles with pyFoam installation. I have followed the wiki:

https://openfoamwiki.net/index.php/C...m#Installation

I didn't success installing in any way (as root, as user, using pip, etc.). I have decided to ask for help step by step.

First, right now I have installed pyfoam using pip. It has been installed into ~/.local/lib/python2.7/site/packages.

This is what I get when I run the steps proposed in the wiki page>

Code:

dan@dan-Gazelle:~$ python
Python 2.7.11+ (default, Apr 17 2016, 14:00:29)
[GCC 5.3.1 20160413] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import PyFoam
>>> import PyFoam.FoamInformation
>>> print PyFoam.FoamInformation.foamTutorials()

>>> import sys
>>> print sys.path
['', '/usr/lib/python2.7/dist-packages', '/usr/lib/python2.7', '/usr/lib/python2.7/plat-x86_64-linux-gnu', '/usr/lib/python2.7/lib-tk', '/usr/lib/python2.7/lib-old', '/usr/lib/python2.7/lib-dynload', '/home/dan/.local/lib/python2.7/site-packages', '/usr/local/lib/python2.7/dist-packages', '/usr/lib/python2.7/dist-packages/gtk-2.0']
>>>
dan@dan-Gazelle:~$ pyFoamVersion.py
Traceback (most recent call last):
  File "/usr/local/bin/pyFoamVersion.py", line 4, in <module>
    __import__('pkg_resources').run_script('PyFoam==0.6.5', 'pyFoamVersion.py')
  File "/usr/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 719, in run_script
    self.require(requires)[0].run_script(script_name, ns)
  File "/usr/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 1496, in run_script
    raise ResolutionError("No script named %r" % script_name)
pkg_resources.ResolutionError: No script named 'pyFoamVersion.py'

What is it that I am doing wrong? Would anyone recommend a better way?

Thanks in advance

jf_vt July 14, 2016 13:47

Hi
I dont know what is wrong but I can tell you that I installed pyfoam on ubuntu16.04 with pip and it worked like a charm.
Now for scientific work I use a locally installed anaconda python installation instead of the systm one's. It make things easier for me.

Danubi July 14, 2016 15:14

Thank you jf_vt,

It is very good to hear that there should not be a problem at least! :)

Now I simply need to find mine... :o


Thanks!

PS: I'll check out the anaconda stuff too, the website looks fine, I wanna get my superpowers too ... hehehe

jf_vt July 14, 2016 15:47

your python version in /usr/lib it is a system installed version
it is usually not recomended to customize system version whih is used by the system.
I had install problems similar to yours in the past ( not with pyfoam) which I did not try to solve once I was advised to install my own version of python to work with( anaconda is a popular choice I like but you have many other options)
google it and you will find everyting you need.
JF

Danubi July 16, 2016 09:50

Hei,

I have already tried to have a different version of python, in my case I used 3.5.2 in a user folder. It didn't succeed either.

I just saw today that there is a very new version of pyFoam (1 day old), the 0.6.6. These pyFoam amazing people just updated some details of the wiki page recommending the "pip" installation. I have tried to download as pip (succeed) but when I tried to import pyFoam in my python I got the following message:

Code:

dan@dan-Gazelle:~/src$ python
Python 2.7.12 (default, Jul  1 2016, 15:12:24)
[GCC 5.4.0 20160609] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import pyFoam
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named pyFoam
>>>

It happened with my default python 2.7.12 installation and with my 3.5.2 shot.

Hopefully the following hours-days the wiki page will be a bit more detailed, if not, please, anybody could drop some light? I am really willing to use pyFoam.

Thank you very much

Minisasi August 25, 2016 13:10

Hi,
Can it be just a typo in your case? From the same link you posted, it looks like PyFoam has a capital P

Code:

import PyFoam
import PyFoam.FoamInformation
print PyFoam.FoamInformation.foamTutorials()

In my case I managed to install PyFoam, but I cannot use it in OpenFoam4.0. I wanted to use the command
Code:

pyFoamPlotRunner.py  MySolverName
but I only get
Code:

pyFoamPlotRunner.py: command not found
Is anybody aware if the combo with OF4.0 is a successful one?
Thanks

Cheers

Danubi August 26, 2016 03:43

Amazing,

My two posts (first and last) disagree with the capital 'P' or not capital 'p'.

I'll try it at some point in the following days and I write down my results.

Thank you!

Minisasi August 26, 2016 12:54

Oh and another thing that may help, but I am sure you have already checked it.
Before typing python and do all that import bla bla bla, I think you have to be in the openFoam shell

zlw306 July 6, 2017 12:13

I have used pip install PyFoam.everything seems well.But when i use print PyFoam.there is no message feedback.i hope someone can help me out...


Sent from my iPhone using CFD Online Forum mobile app

wyldckat July 9, 2017 07:45

Quote:

Originally Posted by zlw306 (Post 656073)
I have used pip install PyFoam.everything seems well.But when i use print PyFoam.there is no message feedback.i hope someone can help me out...

Quick questions:
  1. Which specific installation mode did you use? Did you install it as root or as normal user?
  2. Does this command work?
    Code:

    pyFoamVersion.py --help
  3. Why did you try using "print PyFoam"?

zlw306 July 9, 2017 09:56

Quote:

Originally Posted by wyldckat (Post 656348)
Quick questions:
  1. Which specific installation mode did you use? Did you install it as root or as normal user?
  2. Does this command work?
    Code:

    pyFoamVersion.py --help
  3. Why did you try using "print PyFoam"?



I have figured it out.i used pip install pyfoam follow the openfoam wiki.but it default install dir is not the same with the environment variable writed on the openfoam wiki.So i need to change the pythonpath to where the pyfoam installed.


Sent from my iPhone using CFD Online Forum mobile app

Danubi July 28, 2017 11:14

Minisasi you were right about the upper-lower case mistake.... :D

Thank you!

hadial January 14, 2022 10:37

I had the same problem and FInally I figured it out as follows:


python3.8
Python 3.8.10 (default, Nov 26 2021, 20:14:08)
[GCC 9.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import PyFoam
>>> import PyFoam.FoamInformation
>>> print (PyFoam.FoamInformation.foamTutorials())
/opt/openfoam8/tutorials



Pay attention to first command python3.8
and also the print, it should be written inside pranthesis


All times are GMT -4. The time now is 22:42.