You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
System.ArgumentException: Illegal characters in path #2376
System.ArgumentException: Illegal characters in path.
at System.IO.Path.CheckInvalidPathChars(String path, Boolean checkAdditional)
at System.IO.Path.Combine(String path1, String path2)
at Python.Runtime.AssemblyManager.d__15.MoveNext()
at System.Linq.Enumerable.FirstOrDefault[TSource](IEnumerable`1 source)
at Python.Runtime.AssemblyManager.LoadAssemblyPath(String name)
at Python.Runtime.CLRModule.AddReference(String name)
DLL is not a new implementation. Same DLL and same path was working fine with python 3.7 and PythonNET 2.4.0. This issue started happening when we upgraded python and Pythonnet versions.
This is not a support forum. If you are using backslashes in strings in Python (and really, almost all programming languages) you have to either escape them or use a raw string literal.In Python that would be r"blabla\blubb".
Sorry it was a typo. Yes, I have escaped the back slash. Its nothing to do with backslash. Because same code works fine when tested with python 3.7 and PythonNET 2.4.0.
Tried to load the same DLL using Assembly.LoadFrom(path) - this works without any issues. But clr.AddReference(path) throws Illegal characters in path exception.
from System.Reflection import Assembly
assembly = Assembly.LoadFrom(path)
(client_env) C:\Automation\Main\drop_hal_pywinauto\TA_HAL>python
Python 3.10.11 (tags/v3.10.11:7d4cc5a, Apr 5 2023, 00:38:17) [MSC v.1929 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
Activity
filmor commentedon May 7, 2024
This is not a support forum. If you are using backslashes in strings in Python (and really, almost all programming languages) you have to either escape them or use a raw string literal.In Python that would be
r"blabla\blubb".manju1847 commentedon May 7, 2024
Sorry it was a typo. Yes, I have escaped the back slash. Its nothing to do with backslash. Because same code works fine when tested with python 3.7 and PythonNET 2.4.0.
manju1847 commentedon May 10, 2024
Tried to load the same DLL using Assembly.LoadFrom(path) - this works without any issues. But clr.AddReference(path) throws Illegal characters in path exception.
from System.Reflection import Assembly
assembly = Assembly.LoadFrom(path)
lostmsu commentedon May 10, 2024
@manju1847 can you share your sys.path? I suspect we stumble on something funky there.
manju1847 commentedon May 10, 2024
echo %PATH%
C:\Program Files\IcedTeaWeb\WebStart\bin;C:\Program Files\Zulu\zulu-8-jre\bin;C:\Program Files (x86)\Zulu\zulu-8-jre\bin;C:\Program Files\Python310\Scripts;C:\Program Files\Python310;C:\Users\fnh3651\AppData\Local\Programs\Python\Python37-32;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0;C:\WINDOWS\System32\OpenSSH;C:\Program Files\dotnet;C:\Users\fnh3651.dnx\bin;C:\Program Files\Microsoft DNX\Dnvm;C:\Program Files\Microsoft SQL Server\130\Tools\Binn;C:\Program Files (x86)\Windows Kits\10\Windows Performance Toolkit;C:\Program Files\Microsoft VS Code\bin;C:\Users\fnh3651\AppData\Local\Programs\Python\Python310\Scripts;C:\Users\fnh3651\AppData\Local\Programs\Python\Python310;C:\Users\fnh3651\AppData\Local\Programs\Python\Python312\Scripts;C:\Users\fnh3651\AppData\Local\Programs\Python\Python312;C:\Users\fnh3651\AppData\Local\Programs\Python\Python37-32\Scripts;C:\Users\fnh3651\AppData\Local\Programs\Python\Python37-32;C:\Users\fnh3651\AppData\Local\Microsoft\WindowsApps;C:\Users\fnh3651.dotnet\tools;C:\TrueBeam\PyWinAuto_HAL_Dependencies\TDSConfigManager;
lostmsu commentedon May 10, 2024
@manju1847 no,
sys.pathof Python.manju1847 commentedon May 10, 2024
(client_env) C:\Automation\Main\drop_hal_pywinauto\TA_HAL>python --version
Python 3.10.11
(client_env) C:\Automation\Main\drop_hal_pywinauto\TA_HAL>where python
C:\Automation\Main\drop_hal_pywinauto\client_env\Scripts\python.exe
C:\Users\svc-pa-autbuild\AppData\Local\Programs\Python\Python310\python.exe
C:\Users\svc-pa-autbuild\AppData\Local\Microsoft\WindowsApps\python.exe
(client_env) C:\Automation\Main\drop_hal_pywinauto\TA_HAL>python
Python 3.10.11 (tags/v3.10.11:7d4cc5a, Apr 5 2023, 00:38:17) [MSC v.1929 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
lostmsu commentedon May 10, 2024
The first line seems suspicious. There are quotes in directory name. These are impossible on Windows.
handle bad paths in sys.path
handle bad paths in sys.path
handle bad paths in sys.path
handle bad paths in sys.path
handle bad paths in sys.path
handle bad paths in sys.path
handle bad paths in sys.path (#2383)
manju1847 commentedon May 11, 2024
You nailed it!!!! Yes, that is the root cause. After removing quotes from sys.path, AddReference is happy. Thanks a lot for helping to resolve this.