When using Tools > Advanced > Open Python 3 Shell in Rhino WIP, Rhino opens a PowerShell terminal configured for Rhino’s CPython environment.
Everything works correctly, but the shell shows this startup error related to an old Conda installation:
Traceback (most recent call last):
File "C:\Users\<username>\AppData\Local\anaconda3\Scripts\conda-script.py", line 11, in <module>
from conda.cli import main
ModuleNotFoundError: No module named 'conda'
After the traceback, the Rhino Python shell works normally. Launching PowerShell normally outside Rhino does not show this error.
So it seems the error is triggered specifically by Rhino’s “Open Python 3 Shell” startup process.
My question is:
what exactly does Rhino execute when opening this shell? Is it just launching PowerShell with some environment variables configured, or are additional startup scripts/activation commands executed behind the scenes?
@Stefano_Menci Python environments are created using python’s builtin virtual environment creator. So on Windows, there is an Scripts/activate.ps1 script in each environment e.g. ~/.rhinocode/py39-rh8/site-envs/default-***/Scripts/activate.ps1
Try resetting the python runtime and check if your still see the error. This might be related to a (maybe failed) conda installation.
Thank you for your reply @eirannejad, but I had already tried that.
I just re-reset the Python runtime (and also updated to the latest WIP), but the issue persists. In the snapshot you can see above the PowerShell terminal opened by Rhino and below the one I opened.
Everything seems to be working well, with the exception of that error message.
I really don’t care. I know my computer has skeletons of old Anaconda installations that I don’t use any longer, but since Rhino seems to wake up those ghosts, I thought I would report it, just in case this is a sympthom of something that can cause issues in the future.
So you have any startup scripts that poweshell might be running when launched? Your conda installation might have added something like that.
I did a bit of research (asked Claude really) and seems like conda on Windows edits your Documents\WindowsPowerShell\profile.ps1 file to add something like this
#region conda initialize
# !! Contents within this block are managed by 'conda init' !!
If (Test-Path "C:\Users\<you>\miniconda3\Scripts\conda.exe") {
(& "C:\Users\<you>\miniconda3\Scripts\conda.exe" "shell.powershell" "hook") | Out-String | ?{$_} | Invoke-Expression
}
#endregion
The only meaningful difference I can see is that the Rhino-opened shell starts already inside Rhino’s Python environment:
C:\Users\<user>\.rhinocode\py313-rh9
with the Rhino environment active. Then PowerShell loads my normal user profile, which contains Conda initialization code.
Conda works fine in my normal PowerShell, but the same Conda initialization fails when PowerShell is opened by Rhino. So this does not look like a broken Conda installation; it looks like the user’s PowerShell profile is being loaded after Rhino has already modified the Python environment.
Even a valid Conda setup can modify PATH, define the conda function, set Python-related environment variables, activate hooks, or otherwise affect Python/Pip resolution.
Would it make sense to launch this PowerShell instance with -NoProfile, unless there is a specific reason you want the user profile to run?
Something like:
powershell.exe -NoProfile ...
That seems safer if this shell is meant to be controlled by Rhino for Rhino’s own Python environment.