Welcome, Guest
Username: Password: Remember me

TOPIC: Python execution problem

Python execution problem 11 years 9 months ago #7176

  • abernard
  • abernard's Avatar
  • OFFLINE
  • Expert Boarder
  • Posts: 210
  • Thank you received: 45
Dear colleagues,

I successfully installed telemac under ubuntu but even if the PATH is correctly set to ../pytel/ I can't run my .py files.

When I type :
>config.py I get No such file or directory

>python config.py I get python: can't open file 'config.py': [Errno 2] No such file or directory

It's working only if I execute from the pytel directory by typing python config.py.
It is problematic because when I want to run a simulation, I have to put my steering file in .../pytel/


Thanks for your help
The administrator has disabled public write access.

Python execution problem 11 years 9 months ago #7195

  • yugi
  • yugi's Avatar
  • OFFLINE
  • openTELEMAC Guru
  • Posts: 851
  • Thank you received: 244
Hi,

You need to add the absolut path to the PATH variable i.e.
export PATH=/home/user/path/to/telemac/pytel:.:$PATH
That should work.
Can you show the command you used?
There are 10 types of people in the world: those who understand binary, and those who don't.
The administrator has disabled public write access.

Python execution problem 11 years 9 months ago #7198

  • abernard
  • abernard's Avatar
  • OFFLINE
  • Expert Boarder
  • Posts: 210
  • Thank you received: 45
Hi Yugi,

My path is correctly set. I've added the pytel directory in my bashrc.
echo $PATH returns
/usr/lib/lightdm/lightdm:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/home/alexis/opentelemac/v6p2/pytel


- When I set my working direcory for example on /home/user/study_case/, if I type telemac2d.py, runcode.py telemac2d, config.py or whatever file.py, i get No such file or directory message. It seems that the pytel content (PATH content) is not recognized or the files .py are not recognized as executable.

- From the same directory, if I add python as prefix like for example python telemac2d.py, I get the following message :
python: can't open file 'config.py': [Errno 2] No such file or directory
It can be a problem of path export from my terminal to python...

Regards,
The administrator has disabled public write access.

Python execution problem 11 years 9 months ago #7203

  • yugi
  • yugi's Avatar
  • OFFLINE
  • openTELEMAC Guru
  • Posts: 851
  • Thank you received: 244
For the second case it si normal if you prefix python you need to add the relative path.
As for the first one do you have more than on python installed?
You can try to add the pytel folder to PYTHONPATH as well.
You can also type the absolute adress when you launch the code.

Hope it helps.
There are 10 types of people in the world: those who understand binary, and those who don't.
The administrator has disabled public write access.

Python execution problem 11 years 9 months ago #7207

  • abernard
  • abernard's Avatar
  • OFFLINE
  • Expert Boarder
  • Posts: 210
  • Thank you received: 45
Adding PYTHONPATH pointing to pytel directory doesn't work. My only version of python is 2.7.3.

When I type which python, I get :
/usr/bin/python

Maybe the first line of the .py files is unconsistent with it ?
You can also type the absolute adress when you launch the code.
That's what I do and it works.

Cheers,
The administrator has disabled public write access.
Moderators: borisb

The open TELEMAC-MASCARET template for Joomla!2.5, the HTML 4 version.