mono - Sagemaker 上的 pythonnet 无法导入 clr
问题描述
出现此错误,我无法从 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 emitSymbolInfo, 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)
- 蟒蛇 3.6.13
- 康达 4.8.4
- 蟒蛇网 2.4.0
类似症状:
尝试导入 clr 时出现 System.DllNotFoundException,尽管引用的程序集存在 #1034:我在正确的目录中确认了 libmono-native.so 库。
解决方案
推荐阅读
- cron - crontab,在一段时间内随机执行一个任务的次数
- qos - 如何在使用 qos 配置文件时手动管理主题实例的生命周期
- python-3.x - 如何使用 Python3 和 Udisks2 以只读方式挂载设备?
- c# - .NET Core 2.2:仅在对象不为空时验证 [必需] 属性
- amazon-web-services - 如何将 AWS S3 存储桶与远程非 AWS 服务器上的文件同步?
- angular - Angular 嵌套路由忽略应用基础 href
- dart - 颤振_TypeError类型'列表
' 不是类型 'Map 的子类型 - java - 如何使用 JavaFX 将图像设置为背景?
- java - 在崩溃或服务器重新启动后启动 java 应用程序
- vba - 如何使用宏关闭跟踪更改?