pyansys环境配置(安装所需的库)

目录

1. 环境配置:

2. pyansys库配合Ansys软件启动代码


1. 环境配置:

试了好多种版本,最终以下版本可以跑通:

注意:Python和ANSYS的版本也会影响到安装包的版本,我使用的配置如下:

Python3.9
ansys2022R1

pyvista==0.37.0
ansys-mapdl-core==0.61.6
pyaedt==0.4.71
ansys-dpf-core==0.4.1
ansys-dpf-post==0.2.2
ansys-grantami-bomanalytics==1.0.1

pip list

结果:

Package                             Version
----------------------------------- ----------
aiohttp                             3.9.1
aiosignal                           1.3.1
ansys-api-mapdl                     0.5.1
ansys-dpf-core                      0.4.1
ansys-dpf-post                      0.2.2
ansys-grantami-bomanalytics         1.0.1
ansys-grantami-bomanalytics-openapi 1.0.0
ansys-grpc-dpf                      0.8.1
ansys-mapdl-core                    0.61.6
ansys-mapdl-reader                  0.53.0
ansys-openapi-common                1.3.0
appdirs                             1.4.4
asttokens                           2.4.1
async-timeout                       4.0.3
attrs                               23.1.0
autobahn                            23.6.2
Automat                             22.10.0
cachetools                          5.3.2
certifi                             2023.11.17
cffi                                1.16.0
charset-normalizer                  3.3.2
colorama                            0.4.6
constantly                          23.10.4
contourpy                           1.2.0
cryptography                        41.0.7
cycler                              0.12.1
decorator                           5.1.1
exceptiongroup                      1.2.0
executing                           2.0.1
fonttools                           4.46.0
frozenlist                          1.4.1
google-api-core                     2.15.0
google-api-python-client            2.111.0
google-auth                         2.25.2
google-auth-httplib2                0.2.0
googleapis-common-protos            1.62.0
grpcio                              1.60.0
httplib2                            0.22.0
hyperlink                           21.0.0
idna                                3.6
imageio                             2.33.1
importlib-metadata                  7.0.0
importlib-resources                 6.1.1
incremental                         22.10.0
ipython                             8.18.1
jedi                                0.19.1
kiwisolver                          1.4.5
matplotlib                          3.8.2
matplotlib-inline                   0.1.6
multidict                           6.0.4
numpy                               1.26.2
packaging                           23.2
parso                               0.8.3
Pillow                              10.1.0
pip                                 21.1.2
platformdirs                        4.1.0
plumbum                             1.8.2
pooch                               1.8.0
progressbar2                        4.2.0
prompt-toolkit                      3.0.43
protobuf                            3.20.3
psutil                              5.9.6
pure-eval                           0.2.2
pyaedt                              0.4.71
pyasn1                              0.5.1
pyasn1-modules                      0.3.0
pycparser                           2.21
pygments                            2.17.2
pyiges                              0.3.1
pyparsing                           3.1.1
pypiwin32                           223
pyspnego                            0.10.2
python-dateutil                     2.8.2
python-utils                        3.8.1
pyvista                             0.37.0
pywin32                             306
requests                            2.31.0
requests-negotiate-sspi             0.5.2
requests-ntlm                       1.2.0
rpyc                                5.0.1
rsa                                 4.9
scipy                               1.11.4
scooby                              0.9.2
setuptools                          57.0.0
six                                 1.16.0
sspilib                             0.1.0
stack-data                          0.6.3
tqdm                                4.66.1
traitlets                           5.14.0
twisted                             23.10.0
twisted-iocpsupport                 1.0.4
txaio                               23.1.1
typing-extensions                   4.9.0
uritemplate                         4.1.1
urllib3                             2.1.0
vtk                                 9.0.3
wcwidth                             0.2.12
wheel                               0.36.2
wslink                              1.12.4
yarl                                1.9.4
zipp                                3.17.0
zope.interface                      6.1

参考:

pip下载扩展包时报错 ValueError: check_hostname requires server_hostname_pip valueerror: check_hostname requires server_hos-CSDN博客

ANSYS二次开发:Python和ANSYS进行交互操作(PyAnsys库,DPF)-CSDN博客

(我按照上面这个ansys二次开发博客的版本安装,还是出错,需要修改,

protobuf和pyvista最容易出错:

cannot import name 'CellType' from 'pyvista'

AttributeError: module 'pyvista.plotting.themes' has no attribute 'DefaultTheme'

基本上经常出现的就是这两个报错,应该就是版本不对的问题,

期间查找了pypi的官网,pyansys官网,ansys-github,pyvista等

也没找到官网对其的详细说法,只能试了

PyAEDT documentation 0.7.7 — PyAEDT (pyansys.com)

2. pyansys库配合Ansys软件启动代码

from ansys.mapdl.core import launch_mapdl
mapdl = launch_mapdl()
print(mapdl)


# Product:             Ansys Mechanical Enterprise
# MAPDL Version:       22.1
# ansys.mapdl Version: 0.61.6

pyansys库配合Ansys软件成功启动:

import os
from ansys.mapdl.core import launch_mapdl

path = os.getcwd().replace("\\", "/")

mapdl = launch_mapdl(run_location=path,
                     exec_file=r"E:\Program Files\ANSYS Inc\v221\ansys\bin\winx64\ANSYS221.exe",
                     additional_switches="-smp")
print(mapdl)


# Product:             Ansys Mechanical Enterprise
# MAPDL Version:       22.1
# ansys.mapdl Version: 0.61.6

 当遇到许可证问题,如mapdl超时等问题时,使用语句:additional_switches=“-smp”

参考:

利用Python运行Ansys Apdl_pymapdl 建模-CSDN博客

os.getcwd()函数的用法-CSDN博客

Python中修改字符串单个字符的方法_python字符串的某一位-CSDN博客

python 报错 SyntaxError: EOL while scanning string literal 问题原因 解决方案 EOL解释-CSDN博客

 Python 获取当前路径(文件及所在文件夹,正斜线)_python 当前路径-CSDN博客

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2023-12-17 13:22:01       98 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2023-12-17 13:22:01       106 阅读
  3. 在Django里面运行非项目文件

    2023-12-17 13:22:01       87 阅读
  4. Python语言-面向对象

    2023-12-17 13:22:01       96 阅读

热门阅读

  1. AI训练师常用的ChatGPT通用提示词模板

    2023-12-17 13:22:01       73 阅读
  2. 大模型入门1: 指令微调

    2023-12-17 13:22:01       50 阅读
  3. 人工智能和机器学习在测试中的应用

    2023-12-17 13:22:01       71 阅读
  4. 绘制一个动物——蟒蛇

    2023-12-17 13:22:01       61 阅读
  5. js字符串的方法

    2023-12-17 13:22:01       64 阅读
  6. 【无标题】

    2023-12-17 13:22:01       60 阅读
  7. Spark SQL中coalesce()函数

    2023-12-17 13:22:01       61 阅读
  8. Other -- 了解网上服务器(ECS、VPS)

    2023-12-17 13:22:01       72 阅读
  9. K-means聚类算法的优缺点及Python实现

    2023-12-17 13:22:01       57 阅读
  10. Hive建表语句

    2023-12-17 13:22:01       55 阅读
  11. 基于遗传算法求解旅行商问题(附Matlab代码)

    2023-12-17 13:22:01       64 阅读