[GIS] Adding python packages to ArcGIS

arcgis-10.4arcpypython

I am using ArcGIS 10.4.1 which comes bundled with Python 2.7.10. I am aware of the fact that to install external python packages, one needs to install "pip". I already have "pip" as "pip" is pre-installed in Python 2.7.9 and in newer versions of Python. I have tried to install the Python module with the correct name "pykalman" from within Windows Command Prompt and not the Winows Python Interpreter. Still, I am getting errors as follows:

enter image description here

Best Answer

In your answer screenshot you opened the python interpreter in your command prompt by typing python. This is similar to the ArcGIS (or QGIS) python consoles. This is where you can write python code, but it is not how you install new python packages.

To install a new package, all you need to do is run pip install <package name> from within your command prompt (not the interpreter). If you have your PATH variable updated correctly (sounds like you do, with C:\Python27\ArcGIS10.4\Scripts included) you should be able to run pip install pykalman-master in the cmd from any directory.

If this doesn't work, please update your answer with the errors you encounter.

EDIT: I just tried installing pykalman-master and that is the wrong package name. Use this instead

pip install pykalman

EDIT 2: I see your updated error message. You have pip installed correctly, and you have the path set correctly, so no worries about any of that. This is clear because "Collection pykalman" is printed to the console (meaning pip is working).

The issue in this case seems to be a firewall on your network that blocks access to the pypi server where pip looks for python packages. Here are other people with similar problems.

This is really beyond the scope of GIS Stack Exchange at this point, but to save you time digging through forums and to give a little bit more context......

You could either talk to your network admin to open the firewall (and once you read the rest of this you may see why that would be worth it), or you could download the pykalman source code and install it directly. This is really not so hard (don't be intimidated! :) ):

  1. go to the pykalman repo here https://github.com/pykalman/pykalman
  2. download the zip file of the repo
  3. upzip anywhere on your file system
  4. in a command prompt, enter the unzipped directory, the one that contains setup.py
  5. run this command

    python setup.py install

which tells python to run the setup.py file, and install the package into your python site-packages directory.

  1. you can now delete the downloaded zip file and the unzipped contents if you want (all the relevant stuff is now in site-packages).

To test that you have installed pykalman (or any python package), run the python interpreter (python) and try import pykalman. If no errors, you are good to go.

HOWEVER: The problem with installing this way is that it won't automatically install all of the other python packages that are pykalman's dependencies (numpy scipy Sphinx numpydoc and nose). I'm pretty sure ArcGIS's python install comes with numpy and scipy, but I doubt you have the others. Meaning, you would likely have to manually install those packages too.

Good luck!