Talk:NsPython plug-in: Difference between revisions
No edit summary |
|||
(One intermediate revision by one other user not shown) | |||
Line 57: | Line 57: | ||
--[[User:Wulmer|wulmer]] 14:06, 4 May 2007 (PDT) | --[[User:Wulmer|wulmer]] 14:06, 4 May 2007 (PDT) | ||
== ExecFile not working == | |||
I noticed that nsPython::execFile statement does not work. By reading source code it is quite obvious as it is missing popstring(filename) in callPythonFile function in nsPython.c. (compare to popstring(command) in callPython function). | |||
Easiest workaround is nsPython::exec "execfile('file.py')" | |||
I've fixed this in the latest 2.7 version I've uploaded [[User:Kelvie|Kelvie]] 18:59, 10 October 2012 (UTC) |
Latest revision as of 18:59, 10 October 2012
My Problem
Hello,
I had a problem that no modules were found by python23.dll, even the test installer in the ZIP file did not work with the external test.py file.
I found out by using FileMon, that the module python files were searched in a subdirectory "python23.zip".
Solution 1
I am using the following source directory structure with the following files:
./ ./nsPython/ ./nsPython/python23.dll ./nsPython/python23.zip/ ./nsPython/python23.zip/copy_reg.py ./nsPython/python23.zip/ntpath.py ./nsPython/python23.zip/os.py ./nsPython/python23.zip/shutil.py ./nsPython/python23.zip/stat.py ./nsPython/python23.zip/types.py ./nsPython/python23.zip/UserDict.py
In the NSI file, I have at the beginning:
ReserveFile "nsPython\python23.dll" ReserveFile "nsPython\python23.zip\*.*"
Then in .onInit I have:
Function .onInit InitPluginsDir SetOutPath "$PLUGINSDIR" File /r "nsPython\*.*" ...
With this setting I was able to use the nsPython plugin without problems. If you need other modules, you get an error message from the nsPython plugin naming the module. Simply copy the module.py file into the python23.zip/ directory.
Solution 2
Another alternative is to adjust the python search path before importing additional libraries. Start your python file with (not tested yet)
import sys sys.path.append("./Lib/") import ...
where you specify the path containing the module files.
Questions ? Comments ?
If you have comments about this, mail me at wulmer{@}web{.}de
--wulmer 14:06, 4 May 2007 (PDT)
ExecFile not working
I noticed that nsPython::execFile statement does not work. By reading source code it is quite obvious as it is missing popstring(filename) in callPythonFile function in nsPython.c. (compare to popstring(command) in callPython function).
Easiest workaround is nsPython::exec "execfile('file.py')"
I've fixed this in the latest 2.7 version I've uploaded Kelvie 18:59, 10 October 2012 (UTC)