Setup Eclipse (PyDev) Virtual Environment: ArcPy?

5097
6
05-22-2016 09:27 AM
PeterWilson
Occasional Contributor III

I have found the following two sites explaining how to setup Python Virtualenv for ArcGIS:

  1. ArcGIS and Virtual Environments part 1: ; ArcGIS and Virtual Environments part 2:​
  2. Calling arcpy from an external virtual Python environment:

I've successfully created a virtual environment under my external drive:

  • E:\Python\Venv\ArcPy64bit

cmd_virtualenv.png

When I followed the second part of ArcGIS and Virtual Environments part 2: as well as Calling arcpy from an external virtual Python environment:​ to create the Python Path file to the ArcPy and my ArcHydroTools is where the comes apart.

As instructed I ran the following within my Python IDLE:

import sys
sys.path

idle_sys_path.png

I then created the Python Path file from the list above:

Python_Path_File.png

I copied the path file (arcpy64bit_paths.pth) under the following directory:

  • E:\Python\Venv\ArcPy64bit\Lib\site-packages

Python_Path_File_Directory.png

When I setup the Python Interpreter using the virtualenv within Eclipse the following paths are recognised:

Virtualenv_Python_Paths.png

ArcPy and ArcHydroTools not recognised:

Arcpy_ArcHydroTools_Not_Recognised.png

When I setup the Python Interpreter using the ArcGIS Python within Eclipse the following paths are recognised:

ArcGIS_Python_Paths.png

ArcPy and ArcHydroTools are recognised:

ArcPy_ArcHydroTools_Recognised.png

Any help to resolve the following will be appreciated, as I really need to use virtualenv to manage my Python Environment due to different versions of packages required.

0 Kudos
6 Replies
DanPatterson_Retired
MVP Emeritus

nothing in Curtis Price​ blog?  Curtis Price's Blog or maybe V Stuart Foote​ might have some thoughts

curtvprice
MVP Esteemed Contributor

Let's be clear first off: I know absolutely nothing about Eclipse.

It's really important to make sure the order of paths in sys.path is correct. I think you may be breaking this by include everything in your .pth file. You should

1. Make sure the virtual environment is compatible with ArcGIS (esp python, numpy versions)

2. Use Esri's .pth file that they put in the \Python27\Desktop10.2x64\site-packates folder. You should only have to copy that file.

If you still are having problems, I suggest comparing the sys.path when launching Esri's 64 bit Python with what you are getting in your virtualenv. The order matters.

PeterWilson
Occasional Contributor III

Hi Curtis

Thanks for the following. I'm currently reading up on sys.path to better understand how it works as well as virtualenv\virtualenvwrapper. I'll post my workflow once I've got it working as I'm also going to be using GitHub for version management of my code.

0 Kudos
PeterWilson
Occasional Contributor III

Hi Curtis Price​ , Dan Patterson

I copied the following two Python pth files:

  • ArcHydroTools.pth
  • DTBGGP64.pth

to the following directory:

  • E:\Python\Venv\ArcPy64bit\Lib\site-packages

When I try to install the the specific versions of python packages required for ArcGIS:

  • Numpy (1.7.1)
  • Matplotlib (1.3.0)
  • xlrd (0.9.2)
  • xlwt (0.7.5)
  • Pyparsing (1.5.7)

based on the python requirements for ArcGIS 10.3.1

I'm unable to install Numpy (1.7.1) within my virtualenv via command line:

Python_CMD_Numpy171_Install.PNG

Python: pip install numpy==1.7.1

Python_CMD_Numpy171_ErrorMessage.PNG

Python: Pip install numpy==1.7.1 error message.

If I install numpy without specifying a version it works perfectly, no error messages. I tried downloading numpy-1.7.1.win32-py2.7.exe​ but unfortunately you are unable to change the directory into which it will install. Any help to resolve the following will truly be appreciated.

0 Kudos
DanPatterson_Retired
MVP Emeritus

Peter,

Sorry I can't help, I have been using at least

python 3.4.x, numpy 1.9.x and scipy 0.16.x for quite a while even when python 2.7.x was the only show in town (I think back to arc 10.1 or so).

I have no need for virtual environments since I just run 3 machines all using different configurations... I find it easier to keep track of stuff than remembering what I booted up on

0 Kudos
curtvprice
MVP Esteemed Contributor

I have never messed with virtualenv - I highly recommend using anaconda instead as you tell it what you want and it finds all compatible dependencies, for example:

conda create -n arc1022 python=2.7.5 numpy=1.7.1 matplotlib=1.3  pandas

it will then create a virtual environment that will work with arcpy for Arc 10.2.2 for you. There are a LOT of dependencies in there that I couldn't imagine being able to keep track of.

Just heard for sure that the plans are to ship Anaconda will be shipped with ArcGIS Pro 1.3. This is really great news.