当执行f2py fib1。f -m fib2 -h fib1。pyf我得到以下错误文件”^ SyntaxError:语法是无效的

时间:2022-09-22 22:54:13

I am using Mac 10.9 and running Python 2.7.8. Currently I am trying to use f2py. I follow the example in the guide and typed

我正在使用Mac 10.9和运行Python 2.7.8。目前我正在尝试使用f2py。我按照指南中的示例输入

$ f2py -c fib1.f -m fib1

and I receive the following error

我收到了如下错误。

Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/2.7/bin/f2py", line 3, in <module>
    import f2py2e
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/f2py2e/__init__.py", line 10, in <module>
    import f2py2e
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/f2py2e/f2py2e.py", line 26, in <module>
    import crackfortran
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/f2py2e/crackfortran.py", line 1586
    as=b['args']

I have tried as well the following command

我已经尝试了以下命令。

$ f2py -c --help-fcompiler

and I receive the as error as above. I hope someone can help me. Regards

我收到了如上的错误。我希望有人能帮助我。问候

1 个解决方案

#1


3  

as is a reserved keyword in Python 2.6+.

as是Python 2.6+中的保留关键字。

Therefore trying to assign to it like this

所以要像这样分配。

as=b['args']

is a syntax error.

是一个语法错误。

It's used in exception handling and the with statement (context managers).

它用于异常处理和with语句(上下文管理器)。

In Python 2.5 you already get a deprecation warning if you're using it:

在Python 2.5中,如果您正在使用它,您已经得到了一个弃用警告:

>>> as='foo'
<stdin>:1: Warning: 'as' will become a reserved keyword in Python 2.6

So that's some really old code you're trying to run. You've basically got two options:

这就是你要运行的一些很旧的代码。你基本上有两个选择:

  • Use Python 2.5 or 2.4 to run it
  • 使用Python 2.5或2.4运行它
  • Or fix the code and replace the variable as with something else.
  • 或者修改代码,用其他东西替换变量。

#1


3  

as is a reserved keyword in Python 2.6+.

as是Python 2.6+中的保留关键字。

Therefore trying to assign to it like this

所以要像这样分配。

as=b['args']

is a syntax error.

是一个语法错误。

It's used in exception handling and the with statement (context managers).

它用于异常处理和with语句(上下文管理器)。

In Python 2.5 you already get a deprecation warning if you're using it:

在Python 2.5中,如果您正在使用它,您已经得到了一个弃用警告:

>>> as='foo'
<stdin>:1: Warning: 'as' will become a reserved keyword in Python 2.6

So that's some really old code you're trying to run. You've basically got two options:

这就是你要运行的一些很旧的代码。你基本上有两个选择:

  • Use Python 2.5 or 2.4 to run it
  • 使用Python 2.5或2.4运行它
  • Or fix the code and replace the variable as with something else.
  • 或者修改代码,用其他东西替换变量。