PowerShell运行python脚本报错:因为在此系统上禁止运行脚本
然后就可以正常运行和调试python脚本了。以管理员身份运行powershell。重启终端:执行以下命令。
·
问题背景:
python环境一直都没出问题,突然运行python脚本报错:
发生异常: ImportError
IMPORTANT: PLEASE READ THIS FOR ADVICE ON HOW TO SOLVE THIS ISSUE!
Importing the numpy C-extensions failed. This error can happen for
many reasons, often due to issues with your setup or how NumPy was
installed.
We have compiled some common reasons and troubleshooting tips at:
https://numpy.org/devdocs/user/troubleshooting-importerror.html
Please note and check the following:
* The Python version is: Python3.7 from "d:\download\anaconda3\envs\remixIT_DA\python.exe"
* The NumPy version is: "1.21.6"
and make sure that they are the versions you expect.
Please carefully study the documentation linked above for further help.
Original error was: DLL load failed: 找不到指定的模块。
ImportError: DLL load failed: 找不到指定的模块。
During handling of the above exception, another exception occurred:
File "E:\File_D\remix_eog2\code\DynamicConv1d.py", line 1, in <module>
import torch
ImportError:
IMPORTANT: PLEASE READ THIS FOR ADVICE ON HOW TO SOLVE THIS ISSUE!
Importing the numpy C-extensions failed. This error can happen for
many reasons, often due to issues with your setup or how NumPy was
installed.
We have compiled some common reasons and troubleshooting tips at:
https://numpy.org/devdocs/user/troubleshooting-importerror.html
Please note and check the following:
* The Python version is: Python3.7 from "d:\download\anaconda3\envs\remixIT_DA\python.exe"
* The NumPy version is: "1.21.6"
and make sure that they are the versions you expect.
Please carefully study the documentation linked above for further help.
Original error was: DLL load failed: 找不到指定的模块
以管理员身份运行powershell
尝试新的跨平台 PowerShell https://aka.ms/pscore6
. : 无法加载文件 C:\Users\Administrator\Documents\WindowsPowerShell\profile.ps1,因为在此系统上禁止运行脚本。有关详细信
息,请参阅 https:/go.microsoft.com/fwlink/?LinkID=135170 中的 about_Execution_Policies。
所在位置 行:1 字符: 3
+ . 'C:\Users\Administrator\Documents\WindowsPowerShell\profile.ps1'
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : SecurityError: (:) [],PSSecurityException
+ FullyQualifiedErrorId : UnauthorizedAccess
PS C:\Users\Administrator> Set-ExecutionPolicy RemoteSigned -Scope CurrentUser
执行策略更改
执行策略可帮助你防止执行不信任的脚本。更改执行策略可能会产生安全风险,如 https:/go.microsoft.com/fwlink/?LinkID=135170
中的 about_Execution_Policies 帮助主题所述。是否要更改执行策略?
[Y] 是(Y) [A] 全是(A) [N] 否(N) [L] 全否(L) [S] 暂停(S) [?] 帮助 (默认值为“N”): Y
PS C:\Users\Administrator> Get-ExecutionPolicy -Scope CurrentUser
RemoteSigned
PS C:\Users\Administrator>
重启终端:执行以下命令
(base) PS E:\File_D\remix_eog2> D:/download/anaconda3/Scripts/activate
(base) PS E:\File_D\remix_eog2> conda activate remixIT_DA
然后就可以正常运行和调试python脚本了。
魔乐社区(Modelers.cn) 是一个中立、公益的人工智能社区,提供人工智能工具、模型、数据的托管、展示与应用协同服务,为人工智能开发及爱好者搭建开放的学习交流平台。社区通过理事会方式运作,由全产业链共同建设、共同运营、共同享有,推动国产AI生态繁荣发展。
更多推荐

所有评论(0)