I have almost finished my first full project using .Net & Python, however when trying the program out on other computers I have hit a problem when importing modules. I couldn't figure out how to set the directory that Python should search to import modules when I first started integrating Python into my application, so I did a kludge-y method where I copied the script into the program's main directory, ran it, and then deleted the script and its compiled equivalent once it had been ran. This works fine on my machine - but I sent it to my friend to test out, and it wouldn't work. The scripts would copy over fine into the program's main directory, but an exception would be tripped when attempting to import the module. I am guessing that the directory that Python searches in is incorrect (not defined?) on their machine. I attempted the following at the very start of my program: string Dir = System.Windows.Forms.Application.ExecutablePath; System.Environment.CurrentDirectory = Dir.Replace( "Buildmeister.exe", "" ); ProgramDir = System.Environment.CurrentDirectory; Python.Runtime.PythonEngine.Initialize( ); Python.Runtime.PythonEngine.RunSimpleString( "sys.path[ 0 ] = '" + ProgramDir + "'" ); Python.Runtime.PythonEngine.RunSimpleString( "chdir( '" + ProgramDir + "'" ); ...But it doesn't work! Is there any simple way to set the directory that python searches for modules? --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.529 / Virus Database: 324 - Release Date: 16/10/2003
participants (1)
-
Michael Reitzenstein