目的:从openseespy官网下载了一个
案列,想测试一下
运行环境:
python 3.8.16
openseespy 3.3.0.1.1
openseespywin 3.3.0.1
问题:在运行时,出现报错如下
Traceback (most recent call last):
File "C:\ProgramData\Miniconda3\envs\lib\site-packages\openseespy\opensees\__init__.py", line 19, in <module>
from openseespywin.opensees import *
File "C:\ProgramData\Miniconda3\envs\lib\site-packages\openseespywin\__init__.py", line 17, in <module>
ctypes.cdll.LoadLibrary(dll_path + '\\tcl86t.dll')
File "C:\ProgramData\Miniconda3\envs\lib\ctypes\__init__.py", line 451, in LoadLibrary
return self._dlltype(name)
File "C:\ProgramData\Miniconda3\envs\lib\ctypes\__init__.py", line 373, in __init__
self._handle = _dlopen(self._name, mode)
FileNotFoundError: Could not find module 'C:\ProgramData\Miniconda3\envs\DLLs\tcl86t.dll' (or one of its dependencies). Try using the full path with constructor syntax.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "D:/ElasticTruss.py", line 1, in <module>
from openseespy.opensees import *
File "C:\ProgramData\Miniconda3\envs\lib\site-packages\openseespy\opensees\__init__.py", line 22, in <module>
raise RuntimeError('Failed to import openseespy on Windows.')
RuntimeError: Failed to import openseespy on Windows.
可以发现,报错是由于openseespy未找到tcl86t.dll文件导致,接而提示无法在windows 导入openseespy。
解决方法:在当前环境中,运行如下代码,可以查找到本地环境中的tcl86t.dll.
from ctypes.util import find_library
theDll = find_library('TCL86T')
print(theDll)
方法一:将查找到的本地.dll文件拷贝到报错代码中提示的文件夹,博主这里是C:\ProgramData\Miniconda3\envs\DLLs
方法二:将本地.dll文件的路径添加到系统环境变量。
当然,查找缺少的.dll文件都可以通过上述代码,不局限于tcl86t.dll。
参考资料:Fail to start · Issue #63 · zhuminjie/OpenSeesPyDoc · GitHub