@@ -541,6 +541,16 @@ def launch_cmd(
541
541
always_use_pip : bool, default: False
542
542
Whether to always use pip for the command or not.
543
543
"""
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
+
544
554
# Handle unexpected bool parameter for linux
545
555
if is_linux_os () and isinstance (extra , bool ):
546
556
extra = ""
@@ -567,7 +577,8 @@ def launch_cmd(
567
577
568
578
if is_vanilla_python and not is_venv :
569
579
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 } "
571
582
572
583
if extra :
573
584
cmd = f"&& { extra } "
@@ -591,7 +602,7 @@ def launch_cmd(
591
602
run_linux_command (py_path , extra , True )
592
603
else :
593
604
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 } "' ,
595
606
shell = True ,
596
607
)
597
608
elif not is_vanilla_python and is_venv :
@@ -608,7 +619,7 @@ def launch_cmd(
608
619
run_linux_command_conda (py_path , extra , True )
609
620
else :
610
621
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 } "' ,
612
623
shell = True ,
613
624
)
614
625
else :
@@ -625,6 +636,6 @@ def launch_cmd(
625
636
run_linux_command_conda (py_path , extra , False )
626
637
else :
627
638
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 } "' ,
629
640
shell = True ,
630
641
)
0 commit comments