I created an IronPython script that imports from Python libraries, such as os, sys, etc. as well as .NET libraries.
It runs perfectly fine from my Visual Studio IronPython solution but I need to deploy this so other people who don't have IronPython or Python installed can run it.
How would I do that?
Requirements:
ipy.exe in C:\Program Files (x86)\IronPython 2.7.1\pyc.py in C:\Program Files (x86)\IronPython 2.7.1\Tools\Scripts\MyProgram.py would be your program.
MyProgram.py is), create a folder called "deploy."cd deploy in the command prompt."C:\Program Files (x86)\IronPython 2.7.1\ipy.exe" "C:\Program Files (x86)\IronPython 2.7.1\Tools\Scripts\pyc.py" /main:..\MyProgram.py /target:exe
This will generate a dll and an exe for MyProgram in the deploy folder.
If you try to run MyProgram.exe and you're importing libraries like os, you may get a No module named ....
Since, I'm using os, I get this error:
If you run "MyProgram.exe" and you're using standard libraries, you might get No module named... errors.
In my case, I got:
Unhandled Exception: IronPython.Runtime.Exceptions.ImportException: No module na med os
...
To fix this issue, copy Lib folder from C:\Program Files (x86)\IronPython 2.7.1\ to the deploy folder you just created. Then, before you import the libraries which are throwing errors, modify MyProgram.py like this:
import sys
sys.path.append("Lib")
# Followed by library imports that were causing you trouble:
import os
As a last step, copy the following files from C:\Program Files (x86)\IronPython 2.7.1\ to deploy folder as well:
-IronPython.dll
-IronPython.Modules.dll
-Microsoft.Dynamic.dll
-Microsoft.Scripting.dll
Now you can zip up your deploy folder and and ship it!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With