通过 Python 代码使用 F2Py

发布于 2024-12-25 03:18:31 字数 467 浏览 6 评论 0原文

如何通过Python使用F2Py而不是在命令行中调用它?

我正在使用 便携式 Python,但无法安装 Python。因此,如果我解压缩包并将所有内容复制到文件夹“site-packages”中,则无法安装除那些工作之外的包。提到这些,也无法更改环境变量,即path(无法更改,附加;),尽管不可能以简短形式调用命令“F2Py”。
虽然 F2Py 是 numpy 的一部分,并且 numpy 安装在可移植的 Python 中,但任何地方都没有安装“F2Py.py”。
问题是如何使用F2Py编译Python中使用的Fortran代码,考虑到访问限制等?
请注意,文件夹中解压有一个 GFortran 二进制文件。

How to use F2Py through Python instead of calling it in command line?

I have a portable Python in use, am not able to install Python. Thus it is not possible to install packages except those work if I unzip the package and copy all to the folder 'site-packages'. Having these mentioned, it is also impossible to change environmental variables, i.e., path (cannot be changed, appended;) though it is not possible to call commands 'F2Py' in short form.
Although F2Py is part of numpy and numpy is installed in the portable Python, there is no 'F2Py.py' installed anywhere.
The question is how to use F2Py to compile Fortran code being used in Python considering the access limtation etc?
Note that there is a GFortran binary unpacked in a folder.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

ヅ她的身影、若隐若现 2025-01-01 03:18:31

虽然我不太明白你的解释,但从第一句话来看,你想要做的似乎是在 python 中获得与 f2py -c -m hello hello.f 等效的内容:

from numpy import f2py
f2py.compile(open('hello.f').read(), 'hello')

Although I don't really understand your explanation, from the first sentence it would seem that what you want to do is to get the equivalent of f2py -c -m hello hello.f in python:

from numpy import f2py
f2py.compile(open('hello.f').read(), 'hello')
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文