[Ironpython-users] Cpython module import: ipy.exe vs. ScriptEngine semantics
☯ D.Snezhkov
dsnezhkov at gmail.com
Thu Aug 3 17:10:46 EDT 2017
Hello,
I am trying to work with prompt_toolkit module in my IronPython
application, and I see different results on interactive import via ipy.exe
vs. called from ScriptEngine.
If I import the module in interactive console (ipy64.exe -X:Frames
-X:BasicConsole) everything works. (I have to force sys,platform to read
'win32', otherwise the value is 'cli' )
>>> sys.path.append(r"C:\Python27\Lib")
>>> sys.path.append(r"C:\Python27\Lib\site-packages")
>>> sys.platform="win32"
>>> try:
... from prompt_toolkit import prompt
... except Exception as e:
... traceback.print_exc(file=sys.stdout)
...
>>> sys.executable
'c:\\IronPython-2.7.7\\ipy64.exe'
However if a file with same instructions is called from C# application with
ScriptEngine with CreateScriptSourceFromFile() API, I get errors on import
(below).
sys.path.append(r"C:\Python27\Lib")
sys.path.append(r"C:\Python27\Lib\site-packages")
try:
sys.platform="win32" # force the use of win32 otherwise it has 'cli'
from prompt_toolkit import prompt
except Exception as e:
traceback.print_exc(file=sys.stdout)
I get the following error:
Traceback (most recent call last):
File ".\pfile.py", line 39, in <module>
import prompt_toolkit
File "C:\Python27\Lib\site-packages\prompt_toolkit\__init__.py", line 16,
in <module>
from .interface import CommandLineInterface
File "C:\Python27\Lib\site-packages\prompt_toolkit\interface.py", line
19, in <module>
from .application import Application, AbortAction
File "C:\Python27\Lib\site-packages\prompt_toolkit\application.py", line
3, in <module>
from .buffer import Buffer, AcceptAction
File "C:\Python27\Lib\site-packages\prompt_toolkit\buffer.py", line 27,
in <module>
import tempfile
File "C:\Python27\Lib\tempfile.py", line 32, in <module>
import io as _io
File "C:\Python27\Lib\io.py", line 69, in <module>
class IOBase(_io._IOBase):
File "C:\Python27\Lib\io.py", line 71, in IOBase
__doc__ = _io._IOBase.__doc__
ValueError: The path is not of a legal form.
How is ipy.exe invocation is different than ScriptEngine, and how can I
properly import the module?
Thanks.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ironpython-users/attachments/20170803/bf46516b/attachment.html>
More information about the Ironpython-users
mailing list