I posted this as a comment on this thread, but as the OP's answer involved messing around copying and pasting files, I think it warrants a new question:
Thank you.
Solved! Go to Solution.
To reiterate Curtis Price's comment
sys.exec_prefix
'C:\\ArcGISPro\\bin\\Python\\envs\\arcgispro-py3'
sys.executable
'C:\\ArcGISPro\\bin\\Python\\envs\\arcgispro-py3\\pythonw.exe'
#---- ArcGIS Pro install folder 'C:\\ArcGISPro ... yours will differ
OK, yes those entries for 10.6 are causing the problem -- you can see on sys.path that they precede the actual places you want to be finding Pro DLLs, which causes the crash. Can you report what the below reports?
import glob
import os
import site
print("PYTHONPATH: {}".format(os.environ.get("PYTHONPATH", "undefined")))
print("PYTHONHOME: {}".format(os.environ.get("PYTHONHOME", "undefined")))
for loc in site.getsitepackages():
for pth in glob.glob(os.path.join(loc, "*.pth")):
print(pth)
with open(pth, 'r') as f:
print(f.read())
That should help debug things.
Thanks,
Shaun
Hi Shaun - here's what I got:
OK, thanks. The issue is that the PYTHONPATH variable is set. PYTHONPATH is tricky, because it is used in the initialization of Python and will preempt other settings on the machine. We fixed a bug for ignoring PYTHONPATH in Pro 2.3, but unsetting this variable should be enough to fix your machine. You can find the environment variables by pressing Win+Break > Advanced System Settings > Environment variables and removing PYTHONPATH entries from the user and system variable panes if it exists. This page on modifying environment variables may be helpful: https://www.computerhope.com/issues/ch000549.htm
Once you've unset that, you can check that its correct by closing and reopening. You'll have to fully close e.g. a Python Command Prompt session for these to be flushed, but if it works, your Pro should work again and you shouldn't see any 10.6 references when checking sys.path.
Cheers,
Shaun
Shaun: great solution having Pro's environment ignore PYTHONPATH, that should save a lot of trouble for users! Color me pleased.
Yes, I'm happy to see this fix go in too! One thing I should note -- it actually retains the PYTHONPATH value, but makes them a lower priority than the DLLs for the environment that is driving Pro. This ensures that Pro will work correctly, but will still allow someone who relied on PYTHONPATH for sharing e.g. a Python module to show up in Pro. The PYTHONPATH fix won't help on the command line, because that's a setting built into the python.exe. For posterity, if anyone hits this on the command line, you can start Python with `python -E` to ignore Python environment variables, or better yet unset PYTHONPATH. If you do need to inject additional locations for Python to find modules, add a .pth file which includes the path into Lib\site-packages.
This did it - simple, yet I never thought to check there. Thanks!
Great! Glad we figured it out.
I'm guessing what's going on is you installed your non-ArcGIS Python and used the installer's defaults to mess with the global windows system paths. This will definitely break Esri's Python instances because the Python sys.path includes folders that conflict with the Python you are using. From Pro, try this to see what's in the python path.
import sys
print(sys.executable)
print("\n".join(sys.path))
Maybe the best solution here is to totally remove Anaconda, repair install ArcGIS Desktop and ArcGIS Pro.