Awesome
Awesome thanks a lot. It works
Hello there. I followed the step by step guide as given at Customizing-Dynamo’s-Python-3-installation
It seems that is an exception that it is not allowing me to install this package
@martin.misol any thoughts on this one ?
@solamour Thanks Solamour ! You really solved a headache in just a second !
You are most welcome @Ahmed_Ramy! Glad it was helpful
Hi Sol! After following your steps, unfortunately this error was thrown :
*" Warning: ImportError : *
IMPORTANT: PLEASE READ THIS FOR ADVICE ON HOW TO SOLVE THIS ISSUE!
Importing the numpy C-extensions failed. This error can happen for
many reasons, often due to issues with your setup or how NumPy was
installed.
We have compiled some common reasons and troubleshooting tips at:
-
https://numpy.org/devdocs/user/troubleshooting-importerror.html*
Please note and check the following: -
- The Python version is: Python3.8 from “C:\Program Files\Autodesk\AutoCAD 2022\C3D\Dynamo\Core\DynamoSandbox.exe”*
-
- The NumPy version is: “1.21.4”*
and make sure that they are the versions you expect.
Please carefully study the documentation linked above for further help.
Original error was: DLL load failed while importing _multiarray_umath: The specified module could not be found.
- The NumPy version is: “1.21.4”*
- [’ File “”, line 8, in \n’, ’ File “C:\Users\DELL\anaconda3\envs\Dynamo\Lib\site-packages\numpy\init.py”, line 150, in \n from . import core\n’, ’ File “C:\Users\DELL\anaconda3\envs\Dynamo\Lib\site-packages\numpy\core\init.py”, line 48, in \n raise ImportError(msg)\n’] "*
I am running dynamo core 2.12, any ideas ??
if you have any error , try with topic here
@Ahmed_Ramy did @chuongmep’s link help?
Thanks for helping Chuong!
Hi Sol ! Thanks for asking. I am really busy this time cause we have other submissions but I’ll try it soon !
Hi,
a workaround to avoid changing the sys.path
for each version of Dynamo
import sys
import clr
import System
import re
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
reDir = System.IO.DirectoryInfo(re.__file__)
path_py3_lib = reDir.Parent.Parent.FullName
sys.path.append(path_py3_lib + r'\Lib\site-packages')
OUT = path_py3_lib
It’s possible to install automatically pip
at initialization Python3 engine for next versions of Dynamo ?
I think should support multiple version of python is better.Python 3.10 support debug error very well but some library still not stable
I think it’s not good to mix Python environments, built-in modules are in the directory C:\Users\<USERNAME>\AppData\Local\python-<VERSION>-embed-amd64.
For Python 3.10 I believe only PythonNet 3.00 supports it
Hi Guys,
Anybody knows how to install open3d?
Thank you,
you can see here , same with install numpy or pandas,
use pip3 install open3d
and follow guide document bellow
I found the step by step description here, seemed a bit cumbersome, so I automated it, at least for a Windows environment. Comments welcome:
#https://github-wiki-see.page/m/DynamoDS/Dynamo/wiki/Customizing-Dynamo%27s-Python-3-installation
import platform, os, subprocess, importlib.util, sys
from System import Environment
from System.Net import WebClient
dirName = f'python-{platform.python_version()}-embed-amd64'
localappdatapath = os.getenv(r'LOCALAPPDATA')
dirPath = os.path.join(localappdatapath, dirName)
assert os.path.isdir(dirPath)
bootstrapPipFilePath = os.path.join(dirPath, 'get-pip.py')
if not os.path.isfile(bootstrapPipFilePath):
WebClient().DownloadFile('https://bootstrap.pypa.io/get-pip.py', bootstrapPipFilePath)
pthFilePath = os.path.join(dirPath, 'python38._pth')
assert os.path.isfile(pthFilePath)
replace = False
with open(pthFilePath, 'r') as f:
lines = f.readlines()
if '#' in lines[-1]:
lines[-1] = lines[-1].replace('#','')
replace = True
if replace:
with open(pthFilePath, 'w') as f:
f.writelines(lines)
pipDirPath = os.path.join(dirPath, 'Scripts')
if not os.path.isdir(pipDirPath):
OUT = f'installing pip in local Python environment: {dirPath}'
batPath = os.path.join(localappdatapath,'Temp', 'pipInstall.bat')
with open(batPath, 'w') as f:
f.write(f'cd {dirPath}\n')
f.write('python get-pip.py')
try: subprocess.run(batPath, check = True) #check argument raises exception when an error occurs
except Exception as ex:
OUT += '\n error while installing pip:'
OUT += '\n' + str(ex)
else:
os.remove(batPath)
OUT += '\n pip succesfully installed'
else: OUT = 'pip was already installed for this local Python environment'
installPackages = IN[0]
if installPackages:
sys.path.append(os.path.join(localappdatapath, r'python-3.8.3-embed-amd64\Lib\site-packages'))
for packageName in installPackages:
spec = importlib.util.find_spec( packageName )
if spec is None:
OUT += f'\n installing {packageName} in local Python environment: {dirPath}'
batPath = os.path.join(localappdatapath,'Temp', packageName+'Install.bat')
with open(batPath, 'w') as f:
f.write(f'cd {dirPath}\n')
f.write('.\Scripts\pip install '+packageName)
try: subprocess.run(batPath, check = True) #check argument raises exception when an error occurs
except Exception as ex:
OUT += f'\n error while installing {packageName}:'
OUT += '\n' + str(ex)
else:
os.remove(batPath)
OUT += f'\n{packageName} succesfully installed'
else: OUT += f'\n{packageName} was already installed for this local Python environment'```
Thank you for the link. It is a great article and it helps me a lot. Very appreciated!!!
Hello and welcome !
it’s a nice idea
, here my version
# More info here
# https://github-wiki-see.page/m/DynamoDS/Dynamo/wiki/Customizing-Dynamo%27s-Python-3-installation
import sys
import clr
import System
import re
pyEngineName = sys.implementation.name
if pyEngineName != "ironpython":
reDir = System.IO.DirectoryInfo(re.__file__)
path_py3_lib = reDir.Parent.Parent.FullName
clr.AddReference("System.Windows.Forms")
import System.Windows.Forms
from System.Windows.Forms import MessageBox, MessageBoxButtons, MessageBoxIcon
init_setup = False
import platform, os, subprocess, importlib.util
from System import Environment
from System.Net import WebClient
#
# get paths
assert os.path.isdir(path_py3_lib)
pipDirPath = os.path.join(path_py3_lib, 'Scripts')
pipfilePath = pipDirPath + "\\pip"
get_pip_path = os.path.join(path_py3_lib, 'get-pip.py')
site_packagepath = os.path.join(path_py3_lib, 'Lib\site-packages')
#
if not os.path.isfile(get_pip_path):
client = WebClient()
client.DownloadFile('https://bootstrap.pypa.io/get-pip.py', get_pip_path)
pthFilePath = os.path.join(path_py3_lib, 'python38._pth')
assert os.path.isfile(pthFilePath)
with open(pthFilePath, 'r+') as f:
lines = f.readlines()
if re.match(r'#import site', lines[-1]) is not None:
lines[-1] = re.sub(r'#', '', lines[-1])
f.writelines(lines)
if not os.path.isdir(pipDirPath):
print(f'installing pip in local Python environment: {path_py3_lib}')
subprocess.Popen(["python", get_pip_path])
# try to update pip
try:
#subprocess.run(['python', '-m', pipfilePath, 'install', '--upgrade pip'], cwd = path_py3_lib)
subprocess.Popen(["python", '-m', pipfilePath, 'install', '--upgrade pip'], cwd = path_py3_lib)
except Exception as ex:
print(str(ex))
init_setup = True
MessageBox.Show("Initialization in Progress...\nWhen installation finished, close Dynamo and relaunch this script to install packages", "Initialization In Progress...", MessageBoxButtons.OK, MessageBoxIcon.Warning)
else:
print('pip was already installed for this local Python environment')
init_setup = False
#
installPackages = IN[0]
if installPackages and not init_setup:
sys.path.append(site_packagepath)
for packageName in installPackages:
spec = importlib.util.find_spec( packageName )
if spec is None:
try:
subprocess.run([pipfilePath, 'install', '--target='+ site_packagepath, packageName], cwd = path_py3_lib)
print(f'{packageName} succesfully installed')
except Exception as ex:
print(f'error while installing {packageName}')
print(str(ex))
else:
print(f"package {packageName} is already installed")
EDIT :
UPDATED CODE HERE
Definitely some improvements there! Thanks!