dolfin team mailing list archive
-
dolfin team
-
Mailing list archive
-
Message #22032
Re: [Question #148708]: Switched from Windows 7 -> Ubuntuto runFEniCS
Question #148708 on DOLFIN changed:
https://answers.launchpad.net/dolfin/+question/148708
Status: Open => Answered
Johan Hake proposed the following answer:
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
You received this question notification because you are a member of
DOLFIN Team, which is an answer contact for DOLFIN.