How to modify the default of ansys mapdl

lth
lth Member Posts: 2 **
edited November 2023 in Structures

When I enter the following code

''

From ansys.mapdl import core as pymapdl

New_ Path="D: ANSYS2022R1 ANSYS Inc v221 analysis bin winx64 ANSYS221. exe"

Pymapdl.change_ Default_ ANSYS_ Path (new_path)

''

The following error occurred, Python=3.8.10, ANSYS mapdl core=0.66.0

CRITICAL - pymapdl_global - logging - handle_exception - Uncaught exception
Traceback (most recent call last):
File "C:/Users/Administrator/PycharmProjects/pythonProject/ansys_test.py", line 4, in
pymapdl.change_default_ansys_path(new_path)
File "D:\Anaconda3_2023\envs\BS3810\lib\site-packages\ansys\tools\path\path.py", line 601, in change_default_ansys_path
_change_default_path("mapdl", exe_loc)
File "D:\Anaconda3_2023\envs\BS3810\lib\site-packages\ansys\tools\path\path.py", line 505, in _change_default_path
config_data = _read_config_file()
File "D:\Anaconda3_2023\envs\BS3810\lib\site-packages\ansys\tools\path\path.py", line 844, in _read_config_file
_migrate_config_file()
File "D:\Anaconda3_2023\envs\BS3810\lib\site-packages\ansys\tools\path\path.py", line 898, in _migrate_config_file
class FileMigrationStrategy:
File "D:\Anaconda3_2023\envs\BS3810\lib\site-packages\ansys\tools\path\path.py", line 899, in FileMigrationStrategy
paths: list[str]
TypeError: 'type' object is not subscriptable

Answers

  • Pernelle Marone-Hitz
    Pernelle Marone-Hitz Member, Moderator, Employee Posts: 871
    100 Answers 500 Comments 250 Likes First Anniversary
    ✭✭✭✭

    Hi @lth, the code in your post is not formatted correctly so it is hard to read, but here are a couple of points you could check:

    • your path definition seems off. Make sure it's a path, maybe by using os.path to define it.
    • Python is case sensitive. There are several inconsistencies in the code you show with capitalized or small-case letters.
    • change_default_ansys_path is a deprecated method, as explained in the help. Use change_default_mapdl_path instead