Switched from Windows 7 -> Ubuntu to run FEniCS

Asked by Kyle

Hello,

I just recently decided to install FEniCS on Ubuntu as suggested by the Python FEniCS tutorial. I am new to any Linux based operating system. After locating the terminal and typing 'sudo apt-get install FEniCS' it began to install what seemed to be all the components I required. Upon completion I attempted to locate any sort of application I could run but was unsuccessful. So my very simple question is how do I run FEniCS/DOLFIN after using the sudo apt-get command I used above?

Kyle

Question information

Language:
English Edit question
Status:
Solved
For:
DOLFIN Edit question
Assignee:
No assignee Edit question
Solved by:
Kyle
Solved:
Last query:
Last reply:
Revision history for this message
Anders Logg (logg) said :
#1

On Fri, Mar 11, 2011 at 03:04:23PM -0000, Kyle Williston wrote:
> New question #148708 on DOLFIN:
> https://answers.launchpad.net/dolfin/+question/148708
>
> Hello,
>
> I just recently decided to install FEniCS on Ubuntu as suggested by the Python FEniCS tutorial. I am new to any Linux based operating system. After locating the terminal and typing 'sudo apt-get install FEniCS' it began to install what seemed to be all the components I required. Upon completion I attempted to locate any sort of application I could run but was unsuccessful. So my very simple question is how do I run FEniCS/DOLFIN after using the sudo apt-get command I used above?
>
> Kyle

FEniCS is a programming environment. You need to start Python. Just
type the following in the terminal and then follow the tutorial:

  python

--
Anders

Revision history for this message
Kyle (kylekyle) said :
#2

Thank you Anders,

I am still having a few troubles. I do not think my python is setup correctly for the installed FEniCS modules. After writing a small program following the tutorial I receive the following error message:

'from: can't read /var/mail/dolfin'

Followed by syntax errors because the functions such as UnitSquare did not get imported properly. I am sure this is because I did not setup a path in python to look for dolfin and I am unsure how to do this exactly.

Thanks again!

Kyle

Revision history for this message
Anders Logg (logg) said :
#3

On Mon, Mar 14, 2011 at 08:26:41PM -0000, Kyle Williston wrote:
> Question #148708 on DOLFIN changed:
> https://answers.launchpad.net/dolfin/+question/148708
>
> Status: Answered => Open
>
> Kyle Williston is still having a problem:
> Thank you Anders,
>
> I am still having a few troubles. I do not think my python is setup
> correctly for the installed FEniCS modules. After writing a small
> program following the tutorial I receive the following error message:
>
> 'from: can't read /var/mail/dolfin'

Hmmm... strange. What program did you write?

Can you try the following simple program:

from dolfin import *
mesh = UnitSquare(4, 4)
plot(mesh)
interactive()

Does that work?

--
Anders

> Followed by syntax errors because the functions such as UnitSquare did
> not get imported properly. I am sure this is because I did not setup a
> path in python to look for dolfin and I am unsure how to do this
> exactly.
>
> Thanks again!

Revision history for this message
Johannes Ring (johannr) said :
#4

Remember to start Python before running the program. That is, first type

  python

and press enter. Then type in the program as suggested by Anders.

Revision history for this message
Kyle (kylekyle) said :
#5

Okay the program you suggested does work if I initially load up Python as Johannes suggested and manually type in the lines. I am confused as to why it will not work running directly from the terminal (as I have done it with other non-dolfin practice python programs). The reason I decided to run programs directly from the terminal is that I was unsure how to change the path python searches for files. I'd like to be able to put all my scripts into the folder ~/bin for example.

Revision history for this message
Johan Hake (johan-hake) said :
#6

On Monday March 14 2011 20:57:04 Kyle Williston wrote:
> Question #148708 on DOLFIN changed:
> https://answers.launchpad.net/dolfin/+question/148708
>
> Status: Answered => Open
>
> Kyle Williston is still having a problem:
> Okay the program you suggested does work if I initially load up Python
> as Johannes suggested and manually type in the lines. I am confused as
> to why it will not work running directly from the terminal (as I have
> done it with other non-dolfin practice python programs). The reason I
> decided to run programs directly from the terminal is that I was unsure
> how to change the path python searches for files. I'd like to be able to
> put all my scripts into the folder ~/bin for example.

You can also run your script directly from the prompt by:

  $ python your_script.py

If you rather want to collect all your script within, let say ~/bin while
including that directory in your $PATH variable you need to do two things:

  1) put

       #!/usr/bin/python

     as your first line in each script.

  2) type:

       chmod +x ~/bin/your_script.py

     for all the script you want to make executable. Otherwise will the
     interpreter not allow you to run the script without the "python" prefix.

I use Python quite alot, and I actually think it is a nice thing to prefix the
script with "python". It makes it more explicit that you use Python. I can
then also have my scripts in separate foldes which are divided by project
instead of having them all in one place.

While developing it is also usefull to use ipython, which is a _much_ better
environment than python. It keeps history and a you can use some magic to get
acces to docstrings and other neat things:

   $ ipython
   Python 2.6.6 (r266:84292, Sep 15 2010, 16:22:56)
   Type "copyright", "credits" or "license" for more information.

   IPython 0.10 -- An enhanced Interactive Python.
   ? -> Introduction and overview of IPython's features.
   %quickref -> Quick reference.
   help -> Python's own help system.
   object? -> Details about 'object'. ?object also works, ?? prints more.

   In [1]: from dolfin import *

   In [2]: VariationalProblem?

and you wil get the whole doc string which explains how you use
VariationalProblem.

But that is just my 2 cents :). Good luck!

Johan

Johan

Revision history for this message
Kyle (kylekyle) said :
#7

Excellent it is now working! Thank you everyone for your help. Also in the tutorial pdf some arguments for functions contained apostrophes that resulted in a syntax error. I had to modify them to my keyboards apostrophe for it to work.