This project has moved and is read-only. For the latest updates, please go here.


Compiled .exe gives"URI formats are not supported"-error when importing pyVISA package


For an application I need te pyVISA Python package. I can run the application fine via cmd "ipy.exe", but when running the compiled exe (with I get following error and the app terminates:

Unhandled Exception: System.ArgumentException: URI formats are not supported.
at Microsoft.Scripting.Actions.Calls.MethodCandidate.Caller.Call(Object[ arg
s, Boolean& shouldOptimize)
at IronPython.Runtime.Types.BuiltinFunction.BuiltinFunctionCaller`6.Call5(Cal
lSite site, CodeContext context, TFuncType func, T0 arg0, T1 arg1, T2 arg2, T3 a
rg3, T4 arg4)
at System.Dynamic.UpdateDelegates.UpdateAndExecute7[T0,T1,T2,T3,T4,T5,T6,TRet
](CallSite site, T0 arg0, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6)
at IronPython.Runtime.Importer.Import(CodeContext context, String fullName, P
ythonTuple from, Int32 level)
at IronPython.Runtime.Operations.PythonOps.InitializeModule(Assembly precompi
led, String main, String[ references)
at PythonMain.Main()

The looks like this:

import sys
sys.path.append(r'C:\Program Files\IronPython 2.6 for .NET 4.0\Lib')
sys.path.append(r'C:\Program Files\IronPython 2.6 for .NET 4.0\Lib\site-packages')
print sys.path
import visa
print ""
print "Hello, World!"

I've tested it on both IP 2.7 and 2.6
Closed Dec 9, 2014 at 8:36 PM by jdhardy
Migrated to GitHub.


geniedelsh wrote Feb 14, 2011 at 2:10 PM

I get the same error when importing VISA via ironpython. What I get translates to the following in Pythons

fp = open("file:///C:/Users/eugene/Project/Win32/Debug/IronPython.DLL/share/pyvisa/.pyvisarc")

If I remove the 'file:///' (i.e. URI) everything is fine.

Now what in IronPython is passing filesystem paths out like that? And how do I fix this without patching my Python installation?

debbes wrote Jul 28, 2011 at 9:17 AM

Yes, indeed. That did the trick for me to. Although it wasn't that obvious, I patched the file in my "C:\Program Files\IronPython 2.6 for .NET 4.0\Lib" folder like this:

Search for the only instance:

fp = open(filename)

and replace it with:

fp = open(str(filename).strip(r"file:///"))

Maybe it has to do with calling a file like that inside a .dll file, that's causing the problem?

wrote Jul 29, 2011 at 5:34 PM

wrote Oct 15, 2011 at 11:04 PM

wrote Mar 4, 2012 at 8:40 AM

wrote Jun 24, 2012 at 6:25 PM

wrote Feb 22, 2013 at 2:09 AM

wrote May 30, 2013 at 5:54 PM

wrote Dec 9, 2014 at 8:36 PM