You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何让ifort在Windows Powershell中正常运行?

在Windows PowerShell中运行Intel Fortran编译器(ifort)的方法

方法1:手动加载oneAPI环境配置脚本

Intel oneAPI Command Prompt的核心是自动加载了环境变量配置脚本,你可以直接在PowerShell中调用这个脚本:

  1. 找到oneAPI的setvars.ps1脚本路径,默认安装路径一般为:
    C:\Program Files (x86)\Intel\oneAPI\setvars.ps1
    
  2. 在PowerShell中运行脚本(指定架构为intel64,32位环境用ia32):
    & "C:\Program Files (x86)\Intel\oneAPI\setvars.ps1" intel64
    
  3. 脚本运行完成后,直接输入ifort即可调用编译器。

方法2:设置PowerShell启动时自动加载环境

如果不想每次手动运行脚本,可以配置PowerShell启动时自动加载:

  1. 检查PowerShell配置文件是否存在:
    Test-Path $PROFILE
    
  2. 若返回False,创建配置文件:
    New-Item -Path $PROFILE -Type File -Force
    
  3. 打开配置文件编辑:
    notepad $PROFILE
    
  4. 在文件中添加以下内容(替换为你的实际脚本路径):
    & "C:\Program Files (x86)\Intel\oneAPI\setvars.ps1" intel64 | Out-Null
    
    加| Out-Null是为了屏蔽脚本的输出信息,避免启动PowerShell时显示冗余内容。
  5. 保存文件后,重启PowerShell即可直接使用ifort。

方法3:使用Intel oneAPI模块工具(可选)

如果你的oneAPI安装了模块环境组件,可以通过module命令加载编译器:

  1. 先初始化模块环境(路径根据实际安装调整):
    & "C:\Program Files (x86)\Intel\oneAPI\modulefiles\init\powershell\init.ps1"
    
  2. 加载最新版本的Intel编译器:
    module load intel/oneapi/compiler/latest
    

常见问题处理

  • 执行策略限制:如果运行脚本时提示无法加载,调整PowerShell执行策略:
    Set-ExecutionPolicy RemoteSigned -Scope CurrentUser
    
  • 路径适配:如果oneAPI安装在非默认路径,需将上述命令中的路径替换为你实际的安装路径。

内容的提问来源于stack exchange,提问作者Raymond

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.21 13:52:15