interesting, I tried and does not work, not sure why. I installed ironpython 2.7.12 :
I tried also this script in dynamo:
import sys
import clr
clr.AddReference('System')
from System.Diagnostics import Process
def run_command(command):
process = Process()
process.StartInfo.UseShellExecute = False
process.StartInfo.RedirectStandardOutput = True
process.StartInfo.FileName = r"C:\Program Files\IronPython 2.7\ipy.exe"
process.StartInfo.Arguments = command
process.Start()
process.WaitForExit()
output = process.StandardOutput.ReadToEnd()
return output.strip()
# Construct the pip install command for olefile from GitHub
pip_command = " -X:Frames -m pip install https://github.com/decalage2/olefile/zipball/master"
# Run the command and get the result
installation_result = run_command(pip_command)
# Output the result to Dynamo
OUT = installation_result
although I dowloaded the library package from the website and extracted in my computer and added total control administraction rights in the folder site-packages of the ironpython installation folder and I believe it has been installed with this other code but I cannot load the library later in a script:
import sys
import clr
clr.AddReference('System')
from System.Diagnostics import Process
from System.IO import Path
# Function to run a command in the IronPython subprocess
def run_command(command, working_directory):
process = Process()
process.StartInfo.UseShellExecute = False
process.StartInfo.RedirectStandardOutput = True
process.StartInfo.RedirectStandardError = True
process.StartInfo.FileName = r"C:\Program Files\IronPython 2.7\ipy.exe"
process.StartInfo.Arguments = command
process.StartInfo.WorkingDirectory = working_directory
process.Start()
process.WaitForExit()
output = process.StandardOutput.ReadToEnd()
errors = process.StandardError.ReadToEnd()
return output + errors
# The directory where the 'setup.py' for 'olefile' is located
# Replace this with the actual path where you have extracted the 'olefile' package
package_directory = r"B:\Descargas\olefile-0.46"
# The command to run the 'setup.py' script
setup_command = "setup.py install"
# Run the command and get the result
installation_result = run_command(setup_command, package_directory)
# Output the result to Dynamo
OUT = installation_result
the result says:
[0] running install
running bdist_egg
running egg_info
writing olefile.egg-info\PKG-INFO
writing top-level names to olefile.egg-info\top_level.txt
writing dependency_links to olefile.egg-info\dependency_links.txt
reading manifest file âolefile.egg-info\SOURCES.txtâ
reading manifest template âMANIFEST.inâ
writing manifest file âolefile.egg-info\SOURCES.txtâ
installing library code to build\bdist.cli\egg
running install_lib
running build_py
creating build\bdist.cli\egg
creating build\bdist.cli\egg\olefile
copying build\lib\olefile\olefile.py â build\bdist.cli\egg\olefile
copying build\lib\olefile_init_.py â build\bdist.cli\egg\olefile
creating build\bdist.cli\egg\EGG-INFO
copying olefile.egg-info\PKG-INFO â build\bdist.cli\egg\EGG-INFO
copying olefile.egg-info\SOURCES.txt â build\bdist.cli\egg\EGG-INFO
copying olefile.egg-info\dependency_links.txt â build\bdist.cli\egg\EGG-INFO
copying olefile.egg-info\top_level.txt â build\bdist.cli\egg\EGG-INFO
creating âdist\olefile-0.46-py2.7.eggâ and adding âbuild\bdist.cli\eggâ to it
removing âbuild\bdist.cli\eggâ (and everything under it)
Processing olefile-0.46-py2.7.egg
removing âc:\program files\ironpython 2.7\lib\site-packages\olefile-0.46-py2.7.eggâ (and everything under it)
creating c:\program files\ironpython 2.7\lib\site-packages\olefile-0.46-py2.7.egg
Extracting olefile-0.46-py2.7.egg to c:\program files\ironpython 2.7\lib\site-packages
olefile 0.46 is already the active version in easy-install.pth
Installed c:\program files\ironpython 2.7\lib\site-packages\olefile-0.46-py2.7.egg
Processing dependencies for olefile==0.46
Finished processing dependencies for olefile==0.46
no previously-included directories found matching âdoc_buildâ
warning: build_py: byte-compiling is disabled, skipping.
warning: install_lib: byte-compiling is disabled, skipping.
zip_safe flag not set; analyzing archive contentsâŚ
Unable to analyze compiled code on this platform.
Please ask the author to include a âzip_safeâ setting (either True or False) in the packageâs setup.py
[1] Failed to import olefile: No module named olefile
I tried to import the library and the output tell me there is no module named future?!!! this is asking me for other library wow. I used this script:
[0] Failed to import olefile: No module named future
[1] [0] .
[1] [1] C:\Program Files\IronPython 2.7\Lib\site-packages\olefile-0.46-py2.7.egg
[1] [2] C:\Program Files\IronPython 2.7\Lib\site-packages\olefile-0.46-py2.7.egg\olefile
import sys
import clr
clr.AddReference('System.IO')
from System.IO import Directory, Path
# Ensure that IronPython can see the olefile module by adding it to sys.path
egg_path = r'C:\Program Files\IronPython 2.7\Lib\site-packages\olefile-0.46-py2.7.egg'
olefile_module_path = Path.Combine(egg_path, 'olefile')
# Append both the egg directory and the olefile module directory to sys.path
if egg_path not in sys.path:
sys.path.append(egg_path)
if olefile_module_path not in sys.path:
sys.path.append(olefile_module_path)
# Now try to import the olefile module
try:
import olefile
import_message = "Successfully imported olefile!"
except Exception as e:
import_message = "Failed to import olefile: {0}".format(e.message)
# Output the result to Dynamo
OUT = import_message, sys.path # Output sys.path for debugging purposes
why so complicated?