Installing Anaconda for Python 3.6 without wrecking Python 2.7

5481
14
Jump to solution
08-13-2018 11:33 AM
JustinBridwell2
Occasional Contributor II

Hey All- I have both Python 2.7 with ArcGIS 10.5 Desktop and Python 3.6 with ArcGIS Pro. A few weeks back, I tried to install Anaconda (w/ Conda, Spyder, Jupyter, etc..) and it somehow overwrote my system settings for Python 2.7 (as well as pip). I noticed that I could no longer use pip or import stuff in 2.7. I uninstall Anaconda and the updated version of pip (it somehow updated the pip version) and everything in 2.7 worked again. Any suggestions on reinstalling Anaconda with wrecking my Python 2.7 development environment again? 

0 Kudos
1 Solution

Accepted Solutions
JustinBridwell2
Occasional Contributor II

This was a difficult question to answer but I was finally able to install Anaconda and having it working with my version of ArcGIS Pro (2.2) and Python (3.6). Most importantly, I can now use both the Jupyter Notebook AND the Spyder IDE. The Jupyter Notebook came bundled with the new version of ArcGIS Pro that I installed, so that issue was taken care of. However, I did a reinstall of Anaconda 3.6 and found that I did not have important packages like arcpy and arcgis (the ArcGIS API for Python essentially). I finally found a a work through that did the trick. Here's a link. Essentially, you have to copy the folder arcgispro-py3 from C:\Program Files\ArcGIS\Pro\bin\Python\envs and paste to C:\Anaconda2\envs. The, rename the copied folder arcgispro-py3 in C:\Anaconda2\envs to arcpro. You have to do 2 main things from there; launch your Anaconda Navigator and check in the Environments tab to make sure that there is an arcpro environment. Then, when you launch Spyder, it will ask you if you want Spyder to access the new arcpro environment. Just click yes. The test it out by typing `:import arcpy`. It should run the code without throwing an error. Finito!

View solution in original post

0 Kudos
14 Replies
JoshuaBixby
MVP Esteemed Contributor

Can you elaborate more on "I noticed that I could no longer use pip or import stuff in 2.7."  After installing Anaconda, how were you trying to execute the 2.7 pip?

0 Kudos
JustinBridwell2
Occasional Contributor II

Well, for example, I might try to run a command like "?pip install arcpy" and it would return an error saying pip is not a command. Since, posting this initial question, I went ahead with installing Anaconda. I have the 'arcgis' package installed through Conda on ArcGIS Pro, but when I try to import it from Jupyter or the Spyder IDE,  I get the error: "ModuleNotFoundError: No module named 'arcgis'". I run $conda list and it shows that arcgis package is installed under my arcgispro-py3 folder. This is my current problem  and what I was trying to avoid. Any suggestions?

0 Kudos
JoshuaBixby
MVP Esteemed Contributor

It sounds like you now have 3 Python installations on your machine:  Python 2.7 from ArcGIS Desktop, Python 3.6 from ArcGIS Pro, and Python 3.6 from Anaconda.  Correct?

What does your PATH environment variable look like, at least the portions tied to Python installations?  How are you launching Jupyter?

Regarding using Spyder, I think there have been some issues lately with it and Pro's bundled Python.  It might be worth a quick search on GeoNet on that topic for other threads.

0 Kudos
JustinBridwell2
Occasional Contributor II

What I didn't realize is that the version running in my arcgispro-py3 environment is 3.5.4. I installed Anaconda 3.6. Now when I try to run >import arcgis I get the error: ModuleNotFoundError. The Anaconda/Continuum documentation says to run >conda install python=3.5 , but in what path? If I just go to my user directory and run >python --version, in the Anaconda command prompt, it says python 3.6.5.

0 Kudos
JoshuaBixby
MVP Esteemed Contributor

If your arcgispro-py3 environment is 3.5.4, you are running an older version of Pro.  Pro 2.1 introduced Python 3.6.x.  Is there a reason you are running an older version?  If you can upgrade, I would start there.

Instead of focusing on all of these symptoms/issues, I think it would be good to step back and focus on what you are trying to achieve.  If you install Pro 2.2.x, the bundled Python distribution is fairly comprehensive and includes ArcPy, ArcGIS API for Python, Jupyter, and many SciPy packages.  Is there a reason you need to install Anaconda?

JustinBridwell2
Occasional Contributor II

I actually have ArcGIS Pro 2.0. This is just what was sent to me (my company IT department - I'm a new employee-trying to set up my dev environment) so I just went with it. My ultimate goal here is to access the arcgis package (specifically >import GIS from arcgis.gis) so that I can utilize the ArcGIS API for Python to make calls to a REST service map server. It was just recommended (by the ArcGIS API documentation and my coworkers) that I use Anaconda with Spyder/Jupyter notebook. At this point I don't think I have the option for Pro 2.2.x. 

0 Kudos
JoshuaBixby
MVP Esteemed Contributor

Besides new functionality and numerous bug fixes, the newer versions of ArcGIS Pro just work with ArcGIS API for Python.  ArcGIS Pro 2.0.x is in Mature Support and will be retired by Esri on January 01, 2019.  Once a product is retired, you won't get any support from Esri, so you will have to upgrade Pro sooner than later, might as well be now.

0 Kudos
JoshuaBixby
MVP Esteemed Contributor

Seeing this question, https://community.esri.com/thread/219658-using-the-arcgis-api-for-python-with-a-rest-service , I assume you got it working, more or less.  I will go ahead and mark this assumed answer.

JustinBridwell2
Occasional Contributor II

Yes. I was able to get Jupyter Notebook working and import the arcgis api module. I pretty much scrapped the full Anaconda install yesterday, but just did a reinstall. The verdict is still out, but I'd like to get Spyder working as my primary 3.6 IDE and use Jupyter for testing.

0 Kudos