Skip to content

Commit df59629

Browse files
authored
fix: conflicting DLLs in Path variable (#344)
1 parent 8fa5f43 commit df59629

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

src/ansys/tools/installer/installed_table.py

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -541,6 +541,16 @@ def launch_cmd(
541541
always_use_pip : bool, default: False
542542
Whether to always use pip for the command or not.
543543
"""
544+
path = os.environ["PATH"].split(";")
545+
altered_path = path.copy()
546+
for p in path:
547+
if (
548+
"Ansys Python Manager\_internal" in p
549+
or "ansys_python_manager\_internal" in p
550+
):
551+
altered_path.remove(p)
552+
myenv = ";".join(altered_path)
553+
544554
# Handle unexpected bool parameter for linux
545555
if is_linux_os() and isinstance(extra, bool):
546556
extra = ""
@@ -567,7 +577,8 @@ def launch_cmd(
567577

568578
if is_vanilla_python and not is_venv:
569579
scripts_path = os.path.join(py_path, "Scripts")
570-
new_path = f"{py_path};{scripts_path};%PATH%"
580+
581+
new_path = f"{py_path};{scripts_path};{myenv}"
571582

572583
if extra:
573584
cmd = f"&& {extra}"
@@ -591,7 +602,7 @@ def launch_cmd(
591602
run_linux_command(py_path, extra, True)
592603
else:
593604
subprocess.call(
594-
f'start {min_win} cmd /K "{py_path}\\Scripts\\activate.bat && cd %userprofile% {cmd}"',
605+
f'start {min_win} cmd /K "set PATH={myenv} && {py_path}\\Scripts\\activate.bat && cd %userprofile% {cmd}"',
595606
shell=True,
596607
)
597608
elif not is_vanilla_python and is_venv:
@@ -608,7 +619,7 @@ def launch_cmd(
608619
run_linux_command_conda(py_path, extra, True)
609620
else:
610621
subprocess.call(
611-
f'start {min_win} cmd /K "{miniforge_path}\\Scripts\\activate.bat && conda activate {py_path} && cd %userprofile% {cmd}"',
622+
f'start {min_win} cmd /K "set PATH={myenv} && {miniforge_path}\\Scripts\\activate.bat && conda activate {py_path} && cd %userprofile% {cmd}"',
612623
shell=True,
613624
)
614625
else:
@@ -625,6 +636,6 @@ def launch_cmd(
625636
run_linux_command_conda(py_path, extra, False)
626637
else:
627638
subprocess.call(
628-
f'start {min_win} cmd /K "{miniforge_path}\\Scripts\\activate.bat && conda activate {py_path} && cd %userprofile% {cmd}"',
639+
f'start {min_win} cmd /K "set PATH={myenv} && {miniforge_path}\\Scripts\\activate.bat && conda activate {py_path} && cd %userprofile% {cmd}"',
629640
shell=True,
630641
)

0 commit comments

Comments
 (0)