diff --git a/spyder/plugins/pythonpath/tests/test_utils.py b/spyder/plugins/pythonpath/tests/test_utils.py index f4c1bdecc82..52c5baf0c23 100644 --- a/spyder/plugins/pythonpath/tests/test_utils.py +++ b/spyder/plugins/pythonpath/tests/test_utils.py @@ -28,6 +28,7 @@ def test_check_path(tmp_path): assert not check_path('lib\\dist-packages') assert not check_path('Lib/site-packages') assert not check_path('Anaconda3/pkgs') + assert not check_path("C:\\Users\\user\\AppData\\Roaming\\Python\\Scripts") else: # One digit Python versions assert not check_path('lib/python3.9/site-packages') diff --git a/spyder/plugins/pythonpath/utils.py b/spyder/plugins/pythonpath/utils.py index 807e88b9176..e0f1e82ef11 100644 --- a/spyder/plugins/pythonpath/utils.py +++ b/spyder/plugins/pythonpath/utils.py @@ -22,9 +22,11 @@ def check_path(path): """ pattern_string = r'(ana|mini|micro)(conda|mamba|forge)\d*(/base)*/pkgs' if os.name == 'nt': + path_appdata = os.getenv("APPDATA").replace('\\', '/') pattern_string = ( f'.*({pattern_string}' - r'|(l|L)ib/(site|dist)-packages).*' + r'|(l|L)ib/(site|dist)-packages.*' + f'|(AppData|{path_appdata})/Roaming/Python).*' ) else: pattern_string = (