6

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

  • Have you tried using pip? – BERA Mar 8 '17 at 10:32
  • After opening the python window from ArcGIS, I have typed pip install <module>, but to no avail. – Sujai Banerji Mar 8 '17 at 10:38
  • Same for me. I use windows command prompt to install packages using pip, see this question on how to: stackoverflow.com/questions/29817447/… – BERA Mar 8 '17 at 10:40
  • I tried pip install <module> in Windows Command Prompt, but that does seem to work either. My "pip" is saved in the following path: C:\Python27\ArcGIS10.4\Scripts. I have also taken care of adding the aforementioned path to the Environmental Variables dialog. – Sujai Banerji Mar 8 '17 at 11:14
  • I think that you should run your command prompt application as Administrator. Please, see my answer. – xunilk Mar 8 '17 at 12:44
4

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!

  • The first three points are bang on. Thereafter, there are some changes which I have mentioned in my answer to my own question. – Sujai Banerji Mar 12 '17 at 13:52
4

To install using pip, if it is correctly installed, I think all that you need to do is:

  1. Make sure that C:\Python27\ArcGIS10.4 is in your Path environment variable
  2. Use python -m pip install <module> from a cmd tool
4

I did the procedure for QGIS but it's the same for ArcGis. My goal is to install 'rdp' (Ramer-Douglas-Peucker algorithm) third party python module. First, run your command prompt application as Administrator. In console, I ran this command:

python -m pip install rdp

At the next image you can see that it was successfully installed.

enter image description here

It's also observed that the package was installed in:

C:\Python27\Lib\site-packages

Edit your PYTHONPATH and copy above text in your 'Environment Variables'. Save changes.

enter image description here

Now, when I launch the QGIS application, 'rdp' is already disponible for the Python Console:

enter image description here

  • There is no need to have a PYTHONPATH environment variable set with the ArcGIS Python installation. – KHibma Mar 8 '17 at 16:51
  • Probably because you can use pip install inside Python Console of ArcGis. In my case it's not possible for QGIS so, I need the PYTHONPATH. – xunilk Mar 8 '17 at 17:04
0
  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. Copy the setup.py file from the unzipped folder and place it in C:\Python27\ArcGIS10.4.
  5. Run Windows Command Prompt as administrator and change the directory.
  6. Run this command: python setup.py install

The output would be as follows:

enter image description here

  • Well, if it works it works, but I don't recommend adding files to C:\Python27\ArcGIS10.4. What you should do is add that path to your environment variable PATH (just as you did with C:\Python27\ArcGIS10.4\Scripts, and I kinda thought you already had??). That way you can run python from any directory, allowing you to use the exact steps I laid out. I recommend that you remove setup.py from C:\Python27\ArcGIS10.4, as a house-keeping measure for down the road. – mr.adam Mar 12 '17 at 15:21
  • All right. What I had added in Environment Variables>System Variables>Path were: C:\Python27 and C:\Python27\ArcGIS10.4\Scripts, but not C:\Python27\ArcGIS10.4. I will add C:\Python27\ArcGIS10.4 to Environment Variables>System Variables>Path as recommended by you. Even I suppose I should remove setup.py from C:\Python27\ArcGIS10.4 to maintain tidiness in that folder. What I do not understand is that when I run Python as administrator, it opens in the following directory: C:\Windows\system32>, even though I have not added C:\Windows\system32> to Environment Variables>System Variables>Path . – Sujai Banerji Mar 13 '17 at 13:18
  • 1
    You now talking about the command prompt, or cmd.exe, not python. If you run the command prompt as a user, it will open in that user's home directory. If you run it as administrator (which doesn't have a home directory) it will open in .....system32. These things have nothing to do with your PATH environment variable. – mr.adam Mar 14 '17 at 15:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.