问题描述
由于此错误,我无法从 SageMaker 导入 clr。 什么样的调整使它成功?
来自 Sagemaker 控制台:
source activate python3
conda install pythonnet
这似乎很好地安装了pythonnet,没有错误。
在python代码中:
import clr
这会产生这个错误:
Traceback (most recent call last):
File "test_clr.py",line 1,in <module>
import clr
ImportError: System.TypeInitializationException: The type initializer for 'Sys' threw an exception. ---> System.DllNotFoundException: /home/ec2-user/anaconda3/envs/python3/lib/../lib/libmono-native.so assembly:<unkNown assembly> type:<unkNown type> member:(null)
at (wrapper managed-to-native) Interop+Sys.LChflagsCanSetHiddenFlag()
at Interop+Sys..cctor () [0x00000] in <aa5dff9b31c64fce86559bbbf6cd364f>:0
--- End of inner exception stack trace ---
at Interop.GetRandomBytes (System.Byte* buffer,system.int32 length) [0x00000] in <aa5dff9b31c64fce86559bbbf6cd364f>:0
at System.Guid.FastNewGuidArray () [0x00020] in <aa5dff9b31c64fce86559bbbf6cd364f>:0
at System.Reflection.Emit.ModuleBuilder..ctor (System.Reflection.Emit.AssemblyBuilder assb,System.String name,System.String fullyqname,System.Boolean emitSymbolInfo,System.Boolean transient) [0x00035] in <aa5dff9b31c64fce86559bbbf6cd364f>:0
at System.Reflection.Emit.AssemblyBuilder.DefineDynamicModule (System.String name,System.String fileName,System.Boolean transient) [0x0005b] in <aa5dff9b31c64fce86559bbbf6cd364f>:0
at System.Reflection.Emit.AssemblyBuilder.DefineDynamicModule (System.String name) [0x00000] in <aa5dff9b31c64fce86559bbbf6cd364f>:0
at Python.Runtime.CodeGenerator..ctor () [0x0002b] in <0e10ac2b10a44c1baa160aa337220b6a>:0
at Python.Runtime.DelegateManager..ctor () [0x00061] in <0e10ac2b10a44c1baa160aa337220b6a>:0
at Python.Runtime.PythonEngine.Initialize (System.Collections.Generic.IEnumerable`1[T] args,System.Boolean setSysArgv,System.Boolean initSigs) [0x0000a] in <0e10ac2b10a44c1baa160aa337220b6a>:0
at Python.Runtime.PythonEngine.Initialize (System.Boolean setSysArgv,System.Boolean initSigs) [0x00005] in <0e10ac2b10a44c1baa160aa337220b6a>:0
at Python.Runtime.PythonEngine.InitExt () [0x00000] in <0e10ac2b10a44c1baa160aa337220b6a>:0
环境:
- Amazon Linux AMI 版本 2018.03
- Mono JIT 编译器版本 6.12.0.90(tarball Fri Mar 5 04:37:13 UTC 2021)
- Python 3.6.13
- 畅达 4.8.4
- pythonnet 2.4.0
类似症状:
System.DllNotFoundException when trying to import clr,despite referenced assembly existing #1034 :我在正确的目录中确认了 libmono-native.so 库。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)