Anaconda: Difference between revisions

From Wildsong
Jump to navigationJump to search
Brian Wilson (talk | contribs)
mNo edit summary
Brian Wilson (talk | contribs)
mNo edit summary
 
(41 intermediate revisions by the same user not shown)
Line 1: Line 1:
My main interest in Anaconda is trying out ArcGIS with Jupyter notebook.
See also [[Visual Studio Code]] which has more recent comments.
With ARcGIS Pro 1.4 this turns out to be very easy. Time to stop using ArcMap.


I installed Anaconda on Plover first, I have not used it there. (I can't access the ESRI ArcPy module from OS/X.)
Anaconda is a Python based platform that is available on MacOS, Windows and Linux.
It uses a package management utility called conda.
 
It's installed as part of ESRI ArcGIS Pro so if you have that then you don't need to install it separately. See [https://pro.arcgis.com/en/pro-app/arcpy/get-started/what-is-conda.htm What is Conda] at ESRI.
 
You can install a gigantic everything-including-the-kitchen-sink version called Anaconda that includes 100's of packages or a more fleet-footed version called miniconda and then install just the packages you need.
 
I used to install miniconda primarily to get spyder, which is a reasonably good IDE and debugger. These days I do most of my Python work on Windows 10 so I use [[Microsoft Visual Studio]].
 
== Suggestions ==
 
''Disclaimer:'' I work mostly in a Windows 10 environment and use ArcGISPro 2.4, ArcGIS Enterprise, and sundry open source packages. At home I use mostly open source on Linux and Windows 10. If life is different for you these notes might not be relevant.
 
If using ArcGIS Desktop aka ArcMap, stop. Use ArcGIS Pro because I deleted all my ArcMap notes. Or look in the history for this page.
 
Use the "conda" that comes with AGP.
 
'''Never install Anaconda, it's very big, install '''miniconda''' then add the packages you will actually use.'''
Here is the [https://conda.io/miniconda.html Miniconda download page].
 
'''Don't install the "workloads" for Python and Anaconda that come from Microsoft with Visual Studio either!'''
If you do then you will need administrative rights every time you want to update or install a package.
If you install Miniconda as yourself (not admin) then you can maintain the packages yourself logged in as a normal user.
Still worse is the process for removing a Python environment that was automatically installed from Visual Studio. Just don't do it. Trust me.
 
Anaconda is convenient if you want to do one giant install and have most everything you need, but it takes a long time to download the 300 or so packages it installs and chances are you will use only a few of them.
 
I tried "Jupyter notebook" because ESRI's pushing it these days and found [[Spyder]] to be a far better match for my needs.
Then I tried using Visual Studio and found it better than Spyder because of its debugger.
 
I installed Anaconda on [[Plover]] (a MacBook) first, I can't access the ESRI "ArcPy" module from OS/X but I can use the "ArcGIS" module. ArcPy is for desktop GIS work. ArcGIS is for talking to ArcGIS Online.


I learned about using Jupyter notebook by watching an ESRI video, "ArcGIS API for Python: Advanced Scripting".
I learned about using Jupyter notebook by watching an ESRI video, "ArcGIS API for Python: Advanced Scripting".
I like the idea of cells and being able to visualize data directly (like displaying a dataset on a map) but
I never need to do that.
Running this code in Spyder generates an error about Javascript. Running it in Jupyter generates a map, because it will send javascript to your browser.
from arcgis.gis import GIS
g = GIS()
g.map()


== Installation ==
== Installation ==


=== Mac ===
=== Windows ===
 
2019-Nov-19 I rewrote these instructions to support AGP
 
2018-May-09 I installed version 3 at work today, 32- and 64-bit.


5-13-17
2018-Jan-25 I have it installed on Windows 7 at work and on Windows 10 at home.
Installing on [[Plover]]


I chose to install for "just me" in the hopes I can keep it contained; I am used to using "brew" to maintain Python in my Mac.
=== Linux ===
It says it will put everything (1.4 GB) in Anaconda3/ in my home folder.
It lied, actually it created anaconda/ and AnacondaProjects.
It also added itself in .bash_profile PATH, I removed it because I am only doing a bit of testing here.
Anaconda understands and uses virtualenv as much as I can these days
so it should not need to stomp over existing settings.


I am doing this today because I read about ESRI embracing Juptyer notebook,  
2017-Jul-09 [[Laysan]] Ubuntu. Installed miniconda3, then "conda3 install spyder" and "conda3 install -c esri arcgis"
and the Jupyter people say installing Anaconda is the best way to get Jupyter on a Mac.


Then I will have to look at whether I need it in the virtual machines I run to use ESRI ArcGIS.
=== Mac ===
 
2017-May-13 Installing on [[Plover]]
 
Download the Miniconda installation shell script and run it. Say "yes" to modifying your PATH.


I am not putting Anaconda onto [[Stellar]], because alas Apple won't update the operating system for her and Anaconda
I am not putting Anaconda onto [[Stellar]], because alas Apple won't update the operating system for her and Anaconda
warns against using old versions of OS/X.
warns against using old versions of OS/X.


=== Windows + ArcGIS 10.5 ===
Create an environment for doing GIS work, thus keeping all the modules contained.


Read this ''before'' plunging into the Anaconda installer. https://my.usgs.gov/confluence/pages/viewpage.action?pageId=540116867
conda create -n gis
source activate gis
conda install spyder
conda install gdal # This installs lots of related packages
conda install -c esri arcgis # this installs ESRI's python api module, "arcgis".
 
When you do 'which spyder' it should show the one installed in the gis environment, for me it's
 
/Users/bwilson/miniconda3/envs/gis/bin/spyder
 
Installing spyder inside the "gis" environment avoids having to mess around with settings and does not pollute the base install
with things like alternative versions of numpy and python.
 
Installing spyder also installs jupyter.
 
=== Windows 10 with ArcGIS Pro ===
 
AGP comes with conda installed already, and uses a default virtual environment "arcgispro-py3"
 
In AGP, you can see what environments are available but the "clone" command fails. I think it's a permission error, after running the powershell clone I can clone my own environments.
From PowerShell, I used the command
 
&'C:\Program Files\ArcGIS\Pro\bin\Python\Scripts\conda' create -v -n arcpro --clone="C:/Program Files/ArcGIS/Pro/bin/Python/envs/arcgispro-py3"
 
which created a new environment in AppData/Local/ESRI/ called "arcpro".
Then you can work with it in the command line
or in AGP by loading it under Project->Python->Manage Environments
 
Once you have your own (non read-only) environment you can add packages using either "conda install" from the command line or "Add Packages" in AGP.
 
Then install gdal from the command line; this command gives you gdal version 3.
 
conda install -c conda-forge gdal
 
At any time if you create an environment that does not work you can delete the folder and then go back and run the powershell command again.
 
=== Windows + Python + GDAL + FGDB ===
 
''I still don't have the FGDB part working but I don't really care any more since I saw the comment in the docs that it can't be used with Annotation Feature Classes. I guess that leave me with trying to get access via [[ArcObjects]].''
 
See also https://github.com/OSGeo/gdal
and https://trac.osgeo.org/gdal
and of course http://www.gdal.org/
 
Download the WHL file you need from https://www.lfd.uci.edu/~gohlke/pythonlibs/#gdal
The one you need matches your bitness (64-bit) and your python version so 64 + Python 3.6 =
GDAL?2.2.3?cp36?cp36m?win_amd64.whl for me.
 
So far...
at an Anaconda 64 bit prompt
 
conda create -n gdalwhl
activate gdalwhl
conda install pip
pip install GDAL?2.2.3?cp36?cp36m?win_amd64.whl
 
Test before going on
 
python
import osgeo.gdal
gdal.__version__
 
should show
 
'2.2.3'
 
Download the FGDB zip from Github, https://github.com/Esri/file-geodatabase-api/tree/master/FileGDB_API_1.5.1
and unzip it
 
=== Windows + ArcGIS 10.7 ===
 
I used to use the following process in Windows 7. I will fix it someday. For the moment I am just running the ArcGIS copy of python, no conda needed.
I found pip is tucked away in C:/Python27/ArcGISx6410.7/Scripts so I added that to my path. Then I upgraded pip with "python -m pip install --upgrade pip".
 
Miniconda 2 downloader: https://conda.io/en/latest/miniconda.html
 
Read this ''before'' plunging into the Anaconda installer.  
https://my.usgs.gov/confluence/display/EGIS/Using+Anaconda+modules+from+the+ESRI+python+environment


'''Why install 32-bit Anaconda?''' So that you can use the Anaconda environment to add and maintain python packages.
'''Why install 32-bit Anaconda?''' So that you can use the Anaconda environment to add and maintain python packages.
Line 37: Line 152:
'''Why install 64-bit Anaconda?''' Same reason, but also so that you can work in a completely up to date and snazzy Anaconda  
'''Why install 64-bit Anaconda?''' Same reason, but also so that you can work in a completely up to date and snazzy Anaconda  
environment that has acess to the ESRI python modules (and therefore all of the ESRI ecosystem.)
environment that has acess to the ESRI python modules (and therefore all of the ESRI ecosystem.)
I installed Anaconda in the VM that I use for ArcGIS Desktop, so that I can try Jupyter with ArcGIS.


NB:
NB:
* I installed both the 32- and 64-bit versions, so that I can use both ArcMap and geoprocessing.
* I installed both the 32- and 64-bit versions, so that I can use both ArcMap and geoprocessing.
* I put the 32-bit version in ~/Anaconda3 and the 64-bit version in ~/Anaconda64
* I put the 32-bit version in miniconda2_32 and the 64-bit version in miniconda2
* I told it NOT to modify my PATH and NOT to change the registry, so that the versions already installed by ESRI will continue to work.
* I told it NOT to modify my PATH and NOT to change the registry, so that the versions already installed by ESRI will continue to work.
* I installed for "Just me" because I am the only one who ever uses this computer.
* I installed for "Just me" because I am the only one who ever uses this computer.
* I never double-click py files to run them so I don't need to change the registry.
* For speed, I used /c/Users/bwilson/Continuum as the folder. When we get new computers next month I will need to reinstall it.
In each environment then find the version numbers you need by running the pyversions.py script from the USGS link.
Then install virtual environments as follows, with appropriate versions.
I used to install spyder and some of the packages below might be left over from that, I don't know.
Installing 1.5.3 of matplotlib works instead of 1.5.2 and the latest numpy seems fine too.
Python 2.7.16 is ''probably'' fine too but I am going with this Esri 2.7.15 thing for now.
Start a 32-bit conda prompt
conda update conda
conda create -n arc10
activate arc10
conda install  python=2.7.15 numpy matplotlib=1.5.3  scipy=0.17.0 pandas pyparsing xlrd xlwt console_shortcut
You can add a bash shell here too.
conda install -c msys2 m2-bash


I never double-click py files to run them so I don't need to change the registry.
Start a 64-bit conda prompt
conda create -n arc10x64
activate arc10x64
conda install -c anaconda git


You can launch an "Anaconda prompt" and type DOS commands or (I have GIT installed) start a git bash shell and type
I do some things with PDF files so I installed this
  conda install -c anaconda-nb-extensions pypdf2
  cd /c/Users/bwilson/Anaconda3
./Scripts/conda update conda
./Scripts/conda create -n arc105 python=2.7.12 matplotlib=1.5.3  scipy=0.18.1 pandas pyparsing xlrd xlwt ipython
cd /c/Users/bwilson/Anaconda64
./Scripts/conda update conda
./Scripts/conda create -n arc105 python=2.7.12 matplotlib=1.5.3  scipy=0.18.1 pandas pyparsing xlrd xlwt ipython


I tried installing the versions recommended by USGS but ended up using some that are newer.
Likewise I want to be able to read Excel .xlsx files.
I won't know if this works until I try it.
conda install -c anaconda openpyxl


Once you have followed all the instructions you should be able to launch an "Anaconda prompt" (either 32 or 64 bit),
You can add a bash shell here too. I run inside Cygwin bash so normally I don't need it.
and then load the arcpy module. If this works, you can now use ArcPy in your Anaconda environment.
conda install -c msys2 m2-bash
 
The process of setting up the environment should create items in your Startup menu with the environment name appended,
use those to get access to arcpy.


The version of Python that launches from ArcGIS will be the same one ESRI installed but it will have access to packages that
The version of Python that launches from ArcGIS will be the same one ESRI installed but it will have access to packages that
you install in the arc105 environment in Anaconda because if the 'zconda.pth' file. Naming it with a 'z' means it loads last and therefore most packages (like scipy and numpy) load from the ESRI directory and only things you have added come from Anaconda.
you install in the arc10 environment in Anaconda because of the 'zconda.pth' file. Naming it with a 'z' means it loads last and therefore most packages (like scipy and numpy) load from the ESRI directory and only things you have added come from Anaconda.


USGS missed only one item in there-- the 32-bit pth file to copy is Desktop.pth but the 64-bit file is DTBGGP64.pth
USGS missed only one item in there-- the 32-bit pth file to copy is Desktop.pth but the 64-bit file is DTBGGP64.pth
which I assume stands for "DeskTop BackGround GeoProcessing 64-bit".
which I assume stands for "DeskTop BackGround GeoProcessing 64-bit".


=== Windows + ArcGIS Pro 1.4 ===
cd /c/Python27/ArcGISx6410.7/Lib/site-packages
cp DTBGGP64.pth /c/Users/bwilson/AppData/Local/Continuum/miniconda2/envs/arc10x64/Lib/site-packages/
 
==== ArcGIS (server) module ====
 
I am talking about arcgis.py here, the module that works with ArcGIS server and requires no special licenses.
In the 64-bit environment (miniconda), create a separate environment,
 
conda update conda
conda create -n arcgis
conda activate arcgis
conda install python
conda install -c esri arcgis
 
This works, now I can connect to my ArcGIS Enterprise Portal to test the connection. This
3 line test will prompt me for a password and then print the properties.
 
from arcgis.gis import GIS
gis = GIS("http://flyingsquirrel.wildsong.biz/portal", username="bullwinkle")
print(gis.properties)
 
=== Windows + ArcGIS Pro ===
 
With AGP, ESRI installs python3 and conda for you but does not update your PATH. They probably tell you how to do that somewhere.
They install it with admin permissions so (as with Microsoft Visual Studio Workloads) you can't change it for example to add packages
unless you have admin access. What you CAN do is clone the environment, leaving the ESRI one untouched, and then use the clone.
 
At version 2.2 of AGP you could have this in your environment
 
CONDAHOME=C:\Program Files\ArcGIS\Pro\bin\Python
 
and add this to PATH so that apps can find conda.exe: '''%CONDAHOME%\Scripts'''
 
Once your path is fixed up you can run a cmd window and use conda to create a new writable environment
 
conda create -n my_arcgispro-py3 --clone="%CONDAHOME%\envs\arcgispro-py3"
 
List the available environments
 
conda info --envs
# conda environments:
#
my_arcgispro-py3        C:\Users\bwilson\AppData\Local\ESRI\conda\envs\my_arcgispro-py3
arcgispro-py3        *  C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3
root                    C:\Program Files\ArcGIS\Pro\bin\Python
 
Switch to the new environment and install gdal there.
 
activate my_arcgispro-py3
conda install gdal
 
This installs the gdal packages (along with about 30 dependencies and 20 updates) into my_arcgispro-py3 environment.
AGP will continue to use the old environment but I don't care because I normally work in Visual Studio
and shell windows anyway.
 
You can list the packages installed.
You should see the correct environment path and arcgispro 2.2 listed in there.
 
conda list
# packages in environment at C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3:
#
arcgis                    1.4.1            py36h52c3b5e_1    esri
arcgispro                2.2                          0    esri
asn1crypto                0.24.0                  py36_0
attrs                    17.4.0                  py36_0
backcall                  0.1.0                    py36_0
... etc etc.
freetype                  2.8                      vc14_0  [vc14]  esri
freexl                    1.0.5                hfa6e2cd_0
future                    0.16.0                  py36_1    esri
gdal                      2.2.2            py36hcebd033_1                      <<<<---- YAY!!!
geos                      3.6.2                h9ef7328_2
...
 
Some old information is here:
https://geonet.esri.com/groups/arcgis-python-api/blog/2017/02/08/arcgis-api-for-python-101-released
 
=== ArcGIS Pro + Visual Studio ===
 
If you are using VS older than 15.7, UPDATE NOW. Then read
[https://docs.microsoft.com/en-us/visualstudio/python/managing-python-environments-in-visual-studio?view=vs-2017 this page about environments and Conda in VS].
 
You can select environments in the Solution Explorer in Python Environments.
Right click Python Environments and select "View all Environments" and the one we cloned
should be listed. You can open an interactive window and type
 
import arcpy
import osgeo.gdal
 
and (if you have install gdal) it should not give any messages.
 
Select the environment, and Intellisense for arcpy and gdal should start working.
 
(Note that I have some extra environments that I set up when experimenting.)
 
[[File:python_environment.png]]


With AGP 1.4, ESRI installs python3 and conda for you.
==== Intellisense ====


Somewhere they probably even tell you how to use it.
In Python Environments, it says it no longer needs the Intellisense database and it's turned off.
Since conda is installed I should be able to install the other components, right?
At first Intellisense did not work so I turned the database thing back on, but that was far worse
so I turned it off and after a few restarts it appears to be working again.


Launch a Python prompt from Start menu as '''administrator''' and then I can use conda to install packages.
[[Category: GIS]]

Latest revision as of 18:34, 16 June 2021

See also Visual Studio Code which has more recent comments.

Anaconda is a Python based platform that is available on MacOS, Windows and Linux. It uses a package management utility called conda.

It's installed as part of ESRI ArcGIS Pro so if you have that then you don't need to install it separately. See What is Conda at ESRI.

You can install a gigantic everything-including-the-kitchen-sink version called Anaconda that includes 100's of packages or a more fleet-footed version called miniconda and then install just the packages you need.

I used to install miniconda primarily to get spyder, which is a reasonably good IDE and debugger. These days I do most of my Python work on Windows 10 so I use Microsoft Visual Studio.

Suggestions

Disclaimer: I work mostly in a Windows 10 environment and use ArcGISPro 2.4, ArcGIS Enterprise, and sundry open source packages. At home I use mostly open source on Linux and Windows 10. If life is different for you these notes might not be relevant.

If using ArcGIS Desktop aka ArcMap, stop. Use ArcGIS Pro because I deleted all my ArcMap notes. Or look in the history for this page.

Use the "conda" that comes with AGP.

Never install Anaconda, it's very big, install miniconda then add the packages you will actually use. Here is the Miniconda download page.

Don't install the "workloads" for Python and Anaconda that come from Microsoft with Visual Studio either! If you do then you will need administrative rights every time you want to update or install a package. If you install Miniconda as yourself (not admin) then you can maintain the packages yourself logged in as a normal user. Still worse is the process for removing a Python environment that was automatically installed from Visual Studio. Just don't do it. Trust me.

Anaconda is convenient if you want to do one giant install and have most everything you need, but it takes a long time to download the 300 or so packages it installs and chances are you will use only a few of them.

I tried "Jupyter notebook" because ESRI's pushing it these days and found Spyder to be a far better match for my needs. Then I tried using Visual Studio and found it better than Spyder because of its debugger.

I installed Anaconda on Plover (a MacBook) first, I can't access the ESRI "ArcPy" module from OS/X but I can use the "ArcGIS" module. ArcPy is for desktop GIS work. ArcGIS is for talking to ArcGIS Online.

I learned about using Jupyter notebook by watching an ESRI video, "ArcGIS API for Python: Advanced Scripting". I like the idea of cells and being able to visualize data directly (like displaying a dataset on a map) but I never need to do that.

Running this code in Spyder generates an error about Javascript. Running it in Jupyter generates a map, because it will send javascript to your browser.

from arcgis.gis import GIS
g = GIS()
g.map()

Installation

Windows

2019-Nov-19 I rewrote these instructions to support AGP

2018-May-09 I installed version 3 at work today, 32- and 64-bit.

2018-Jan-25 I have it installed on Windows 7 at work and on Windows 10 at home.

Linux

2017-Jul-09 Laysan Ubuntu. Installed miniconda3, then "conda3 install spyder" and "conda3 install -c esri arcgis"

Mac

2017-May-13 Installing on Plover

Download the Miniconda installation shell script and run it. Say "yes" to modifying your PATH.

I am not putting Anaconda onto Stellar, because alas Apple won't update the operating system for her and Anaconda warns against using old versions of OS/X.

Create an environment for doing GIS work, thus keeping all the modules contained.

conda create -n gis
source activate gis
conda install spyder
conda install gdal # This installs lots of related packages
conda install -c esri arcgis # this installs ESRI's python api module, "arcgis".

When you do 'which spyder' it should show the one installed in the gis environment, for me it's

/Users/bwilson/miniconda3/envs/gis/bin/spyder

Installing spyder inside the "gis" environment avoids having to mess around with settings and does not pollute the base install with things like alternative versions of numpy and python.

Installing spyder also installs jupyter.

Windows 10 with ArcGIS Pro

AGP comes with conda installed already, and uses a default virtual environment "arcgispro-py3"

In AGP, you can see what environments are available but the "clone" command fails. I think it's a permission error, after running the powershell clone I can clone my own environments. From PowerShell, I used the command

&'C:\Program Files\ArcGIS\Pro\bin\Python\Scripts\conda' create -v -n arcpro --clone="C:/Program Files/ArcGIS/Pro/bin/Python/envs/arcgispro-py3"

which created a new environment in AppData/Local/ESRI/ called "arcpro". Then you can work with it in the command line or in AGP by loading it under Project->Python->Manage Environments

Once you have your own (non read-only) environment you can add packages using either "conda install" from the command line or "Add Packages" in AGP.

Then install gdal from the command line; this command gives you gdal version 3.

conda install -c conda-forge gdal

At any time if you create an environment that does not work you can delete the folder and then go back and run the powershell command again.

Windows + Python + GDAL + FGDB

I still don't have the FGDB part working but I don't really care any more since I saw the comment in the docs that it can't be used with Annotation Feature Classes. I guess that leave me with trying to get access via ArcObjects.

See also https://github.com/OSGeo/gdal and https://trac.osgeo.org/gdal and of course http://www.gdal.org/

Download the WHL file you need from https://www.lfd.uci.edu/~gohlke/pythonlibs/#gdal The one you need matches your bitness (64-bit) and your python version so 64 + Python 3.6 = GDAL?2.2.3?cp36?cp36m?win_amd64.whl for me.

So far... at an Anaconda 64 bit prompt

conda create -n gdalwhl
activate gdalwhl
conda install pip
pip install GDAL?2.2.3?cp36?cp36m?win_amd64.whl

Test before going on

python
import osgeo.gdal
gdal.__version__

should show

'2.2.3'

Download the FGDB zip from Github, https://github.com/Esri/file-geodatabase-api/tree/master/FileGDB_API_1.5.1 and unzip it

Windows + ArcGIS 10.7

I used to use the following process in Windows 7. I will fix it someday. For the moment I am just running the ArcGIS copy of python, no conda needed. I found pip is tucked away in C:/Python27/ArcGISx6410.7/Scripts so I added that to my path. Then I upgraded pip with "python -m pip install --upgrade pip".

Miniconda 2 downloader: https://conda.io/en/latest/miniconda.html

Read this before plunging into the Anaconda installer. https://my.usgs.gov/confluence/display/EGIS/Using+Anaconda+modules+from+the+ESRI+python+environment

Why install 32-bit Anaconda? So that you can use the Anaconda environment to add and maintain python packages. Arguably you could replace the entire ESRI Python with Anaconda Python but I don't suggest doing this.

Why install 64-bit Anaconda? Same reason, but also so that you can work in a completely up to date and snazzy Anaconda environment that has acess to the ESRI python modules (and therefore all of the ESRI ecosystem.)

NB:

  • I installed both the 32- and 64-bit versions, so that I can use both ArcMap and geoprocessing.
  • I put the 32-bit version in miniconda2_32 and the 64-bit version in miniconda2
  • I told it NOT to modify my PATH and NOT to change the registry, so that the versions already installed by ESRI will continue to work.
  • I installed for "Just me" because I am the only one who ever uses this computer.
  • I never double-click py files to run them so I don't need to change the registry.
  • For speed, I used /c/Users/bwilson/Continuum as the folder. When we get new computers next month I will need to reinstall it.

In each environment then find the version numbers you need by running the pyversions.py script from the USGS link. Then install virtual environments as follows, with appropriate versions. I used to install spyder and some of the packages below might be left over from that, I don't know. Installing 1.5.3 of matplotlib works instead of 1.5.2 and the latest numpy seems fine too. Python 2.7.16 is probably fine too but I am going with this Esri 2.7.15 thing for now.

Start a 32-bit conda prompt

conda update conda
conda create -n arc10
activate arc10
conda install  python=2.7.15 numpy matplotlib=1.5.3  scipy=0.17.0 pandas pyparsing xlrd xlwt console_shortcut

You can add a bash shell here too.

conda install -c msys2 m2-bash

Start a 64-bit conda prompt

conda create -n arc10x64
activate arc10x64
conda install -c anaconda git

I do some things with PDF files so I installed this

conda install -c anaconda-nb-extensions pypdf2

Likewise I want to be able to read Excel .xlsx files.

conda install -c anaconda openpyxl 

You can add a bash shell here too. I run inside Cygwin bash so normally I don't need it.

conda install -c msys2 m2-bash

The process of setting up the environment should create items in your Startup menu with the environment name appended, use those to get access to arcpy.

The version of Python that launches from ArcGIS will be the same one ESRI installed but it will have access to packages that you install in the arc10 environment in Anaconda because of the 'zconda.pth' file. Naming it with a 'z' means it loads last and therefore most packages (like scipy and numpy) load from the ESRI directory and only things you have added come from Anaconda.

USGS missed only one item in there-- the 32-bit pth file to copy is Desktop.pth but the 64-bit file is DTBGGP64.pth which I assume stands for "DeskTop BackGround GeoProcessing 64-bit".

cd /c/Python27/ArcGISx6410.7/Lib/site-packages
cp DTBGGP64.pth /c/Users/bwilson/AppData/Local/Continuum/miniconda2/envs/arc10x64/Lib/site-packages/

ArcGIS (server) module

I am talking about arcgis.py here, the module that works with ArcGIS server and requires no special licenses. In the 64-bit environment (miniconda), create a separate environment,

conda update conda
conda create -n arcgis
conda activate arcgis
conda install python
conda install -c esri arcgis

This works, now I can connect to my ArcGIS Enterprise Portal to test the connection. This 3 line test will prompt me for a password and then print the properties.

from arcgis.gis import GIS
gis = GIS("http://flyingsquirrel.wildsong.biz/portal", username="bullwinkle")
print(gis.properties)

Windows + ArcGIS Pro

With AGP, ESRI installs python3 and conda for you but does not update your PATH. They probably tell you how to do that somewhere. They install it with admin permissions so (as with Microsoft Visual Studio Workloads) you can't change it for example to add packages unless you have admin access. What you CAN do is clone the environment, leaving the ESRI one untouched, and then use the clone.

At version 2.2 of AGP you could have this in your environment

CONDAHOME=C:\Program Files\ArcGIS\Pro\bin\Python

and add this to PATH so that apps can find conda.exe: %CONDAHOME%\Scripts

Once your path is fixed up you can run a cmd window and use conda to create a new writable environment

conda create -n my_arcgispro-py3 --clone="%CONDAHOME%\envs\arcgispro-py3"

List the available environments

conda info --envs
# conda environments:
#
my_arcgispro-py3         C:\Users\bwilson\AppData\Local\ESRI\conda\envs\my_arcgispro-py3
arcgispro-py3         *  C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3
root                     C:\Program Files\ArcGIS\Pro\bin\Python

Switch to the new environment and install gdal there.

activate my_arcgispro-py3
conda install gdal

This installs the gdal packages (along with about 30 dependencies and 20 updates) into my_arcgispro-py3 environment. AGP will continue to use the old environment but I don't care because I normally work in Visual Studio and shell windows anyway.

You can list the packages installed. You should see the correct environment path and arcgispro 2.2 listed in there.

conda list
# packages in environment at C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3:
#
arcgis                    1.4.1            py36h52c3b5e_1    esri
arcgispro                 2.2                           0    esri
asn1crypto                0.24.0                   py36_0
attrs                     17.4.0                   py36_0
backcall                  0.1.0                    py36_0
... etc etc.
freetype                  2.8                      vc14_0  [vc14]  esri
freexl                    1.0.5                hfa6e2cd_0
future                    0.16.0                   py36_1    esri
gdal                      2.2.2            py36hcebd033_1                      <<<<---- YAY!!!
geos                      3.6.2                h9ef7328_2
...

Some old information is here: https://geonet.esri.com/groups/arcgis-python-api/blog/2017/02/08/arcgis-api-for-python-101-released

ArcGIS Pro + Visual Studio

If you are using VS older than 15.7, UPDATE NOW. Then read this page about environments and Conda in VS.

You can select environments in the Solution Explorer in Python Environments. Right click Python Environments and select "View all Environments" and the one we cloned should be listed. You can open an interactive window and type

import arcpy
import osgeo.gdal

and (if you have install gdal) it should not give any messages.

Select the environment, and Intellisense for arcpy and gdal should start working.

(Note that I have some extra environments that I set up when experimenting.)

Intellisense

In Python Environments, it says it no longer needs the Intellisense database and it's turned off. At first Intellisense did not work so I turned the database thing back on, but that was far worse so I turned it off and after a few restarts it appears to be working again.