This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Can't get f2py to work at all
Type: Stage:
Components: Versions:
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: PeterJones, benjamin.peterson, brian.curtin, eric.araujo
Priority: normal Keywords:

Created on 2010-02-28 22:45 by PeterJones, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
unnamed PeterJones, 2010-02-28 22:45
Messages (6)
msg100225 - (view) Author: Peter Jones (PeterJones) Date: 2010-02-28 22:45
I am user 11943. OS is Windows Vista Ultimate. I have followed the instructions on how to use f2py and get this error when I try it (is this a known bug? It appears that there is bug in f2py):

C:\Python26\Scripts>python f2py.py
Traceback (most recent call last):
  File "f2py.py", line 3, in <module>
    import f2py2e
  File "C:\Python26\lib\site-packages\f2py2e\__init__.py", line 10, in <module>
    import f2py2e
  File "C:\Python26\lib\site-packages\f2py2e\f2py2e.py", line 26, in <module>
    import crackfortran
  File "C:\Python26\lib\site-packages\f2py2e\crackfortran.py", line 1586
    as=b['args']
     ^
SyntaxError: invalid syntax

I have also tried the example to create a fortran module for python and get this error:

C:\Python26\Scripts>python f2py.py -c --fcompiler=gnu95 --compiler=mingw32 -lmsvcr71 -m cep cep.for

Traceback (most recent call last):
  File "f2py.py", line 3, in <module>
    import f2py2e
  File "C:\Python26\lib\site-packages\f2py2e\__init__.py", line 10, in <module>
    import f2py2e
  File "C:\Python26\lib\site-packages\f2py2e\f2py2e.py", line 26, in <module>
    import crackfortran
  File "C:\Python26\lib\site-packages\f2py2e\crackfortran.py", line 1586
    as=b['args']
     ^
SyntaxError: invalid syntax

Additionally I use the Lahey/Fujitsu 95 compiler. Do I just replace the gnu95 with lahey? 
Also Is the msvrc71.dll file the correct one to use? I use MSVC VS 2009, which uses msvc90.dll. Should I use it instead?
msg100227 - (view) Author: Benjamin Peterson (benjamin.peterson) * (Python committer) Date: 2010-02-28 23:52
This is a 3rd party package problem. Please ask the maintainers of it.
msg100229 - (view) Author: Peter Jones (PeterJones) Date: 2010-03-01 00:40
I would like to recall this bug report. What happend was I went to the f2py 
web site and dowloaded the "latest" version and installed it over Pythoh 
x,y. So I uninstalled P x,y and resinstalled and the f2py works OK now. Some 
one should make it more clear in the documentation to not do what I did.

Peter.

----- Original Message ----- 
From: "Peter Jones" <report@bugs.python.org>
To: <pjones0@hughes.net>
Sent: Sunday, February 28, 2010 2:45 PM
Subject: [issue8031] Can't get f2py to work at all

New submission from Peter Jones <pjones0@hughes.net>:

I am user 11943. OS is Windows Vista Ultimate. I have followed the 
instructions on how to use f2py and get this error when I try it (is this a 
known bug? It appears that there is bug in f2py):

C:\Python26\Scripts>python f2py.py
Traceback (most recent call last):
  File "f2py.py", line 3, in <module>
    import f2py2e
  File "C:\Python26\lib\site-packages\f2py2e\__init__.py", line 10, in 
<module>
    import f2py2e
  File "C:\Python26\lib\site-packages\f2py2e\f2py2e.py", line 26, in 
<module>
    import crackfortran
  File "C:\Python26\lib\site-packages\f2py2e\crackfortran.py", line 1586
    as=b['args']
     ^
SyntaxError: invalid syntax

I have also tried the example to create a fortran module for python and get 
this error:

C:\Python26\Scripts>python 
f2py.py -c --fcompiler=gnu95 --compiler=mingw32 -lmsvcr71 -m cep cep.for

Traceback (most recent call last):
  File "f2py.py", line 3, in <module>
    import f2py2e
  File "C:\Python26\lib\site-packages\f2py2e\__init__.py", line 10, in 
<module>
    import f2py2e
  File "C:\Python26\lib\site-packages\f2py2e\f2py2e.py", line 26, in 
<module>
    import crackfortran
  File "C:\Python26\lib\site-packages\f2py2e\crackfortran.py", line 1586
    as=b['args']
     ^
SyntaxError: invalid syntax

Additionally I use the Lahey/Fujitsu 95 compiler. Do I just replace the 
gnu95 with lahey?
Also Is the msvrc71.dll file the correct one to use? I use MSVC VS 2009, 
which uses msvc90.dll. Should I use it instead?

----------
files: unnamed
messages: 100225
nosy: PeterJones
severity: normal
status: open
title: Can't get f2py to work at all
Added file: http://bugs.python.org/file16402/unnamed

_______________________________________
Python tracker <report@bugs.python.org>
<http://bugs.python.org/issue8031>
_______________________________________
msg100239 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2010-03-01 03:12
Hello

This is indeed a problem with f2py. Please tell its maintaines that they can’t name an object “as” since it’s a reserved keyword in Python 2.6 and higher. Testing with 2.5 (previous stable version, released in 2006) would have shown it: <http://www.python.org/doc/2.5/whatsnew/pep-343.html> points to <http://www.python.org/dev/peps/pep-0343/> which tells in “Transition Plan”:

    “In Python 2.5, the new syntax will only be recognized if a future
    statement is present:

          from __future__ import with_statement

    This will make both 'with' and 'as' keywords.  Without the future
    statement, using 'with' or 'as' as an identifier will cause a
    Warning to be issued to stderr.

    In Python 2.6, the new syntax will always be recognized; 'with'
    and 'as' are always keywords.”

So we’ll close here, since it is a normal, documented behavior. The f2py people have to fix their code.

Regards
msg100240 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2010-03-01 03:16
While I’m thinking about this, is there a way to make the syntax error traceback more informative, i.e. adding “'{}' is a reserved keyword” in such cases?
msg100241 - (view) Author: Brian Curtin (brian.curtin) * (Python committer) Date: 2010-03-01 03:29
That is still a third-party issue, something f2py or Python x,y will have to take care of.

In your report, you should tell f2py to not use "as" as a variable name.
History
Date User Action Args
2022-04-11 14:56:58adminsetgithub: 52279
2010-03-01 03:29:45brian.curtinsetnosy: + brian.curtin
messages: + msg100241
2010-03-01 03:16:32eric.araujosetmessages: + msg100240
2010-03-01 03:12:54eric.araujosetnosy: + eric.araujo
messages: + msg100239
2010-03-01 00:40:40PeterJonessetmessages: + msg100229
2010-02-28 23:52:36benjamin.petersonsetstatus: open -> closed

nosy: + benjamin.peterson
messages: + msg100227

resolution: not a bug
2010-02-28 22:45:27PeterJonescreate