0

I want to make 2 version (python v3 and python v2) working. I have installed both the versions at different directories. I have also placed their location at the Environment Variables/Path. But, only one version i.e python3 works from command prompt. Yes, for removing the conflict of same filename, I have renamed the python.exe of python v3 to python3.exe

Why is python2 not working??

Using:

python

throws error: 'python' is not recognized as an internal or external command, operable program or batch file.

Directories:

Python3: C:\Python36
Python2: C:\Python27\ArcGIS10.4

Paths on Environment Variables/Path:

C:\Program Files (x86)\Intel\iCLS Client\;C:\Program Files\Intel\iCLS Client\;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\Common Files\Lenovo;C:\SWTOOLS\ReadyApps;C:\Program Files\SASHome\x86\Secure\ccme4;C:\Program Files\SASHome\Secure\ccme4;C:\Program Files (x86)\Intel\UCRT\;C:\Program Files\Intel\UCRT\;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files\Intel\Intel(R) Management Engine Components\IPT;C:\cygnus\cygwin-b20\H-i586-cygwin32\bin; C:\Python36;C:\Python27\ArcGIS10.4 
pnkjmndhl
  • 565
  • 3
  • 7
  • 21
  • environment variable only has the name of the directory. I have renamed the filename. So, that shouldn't make any difference. – pnkjmndhl Apr 27 '17 at 19:49
  • python3 works. I am concerned about python2. – pnkjmndhl Apr 27 '17 at 19:51
  • paths for both are added?? – Rajeev Singh Apr 27 '17 at 19:53
  • Yes. I can even run both of them from their respective directories. – pnkjmndhl Apr 27 '17 at 19:55
  • there could be another issue... u should provide the env variable and directory structure in ques ... it may help!! – Rajeev Singh Apr 27 '17 at 19:58
  • you state above that the path contains: `C:\Python36; C:\Python27\ArcGIS10.4`. if so, you are missing the path `C:\Python27` (no other file or subdirectory). –  Apr 27 '17 at 20:15
  • why would python two be inside ArcGIS10.4? Is 'ArcGIS10.4' a directory or a file?? –  Apr 27 '17 at 20:16
  • 1
    this may help http://stackoverflow.com/questions/3701646/how-to-add-to-the-pythonpath-in-windows-7 – Rajeev Singh Apr 27 '17 at 20:16
  • python27 was installed on my PC by a third party application ArcGIS. Thus, its not installed on the conventional location, rather: C:\python27\ArcGIS10.4 – pnkjmndhl Apr 27 '17 at 20:17
  • That sounds like a problem in itself. I would remove it and re-install actual python from python.org.. in the correct directory. It sounds like the python.exe is not in the ArcGIS10.4 folder to me.. you may wich to browse to that directory from windows explorer and verify python.exe is there –  Apr 27 '17 at 20:18
  • If I installed it to a different path, I am afraid it will not be accessible from the program itself. – pnkjmndhl Apr 27 '17 at 20:19
  • verify the executable exists at that exact location. –  Apr 27 '17 at 20:20
  • Yes it does. I can even run it from it's location. The problem is, I have to go it's default directory everytime I try to run it. – pnkjmndhl Apr 27 '17 at 20:22
  • try `python.exe` instead of `python` –  Apr 27 '17 at 20:24
  • No that doesn't work either. – pnkjmndhl Apr 27 '17 at 20:26
  • 1
    If that does not work, there must be a syntax error in the path (are you really providing the whole file for us to see.. seems like more should be there than just `C:\Python36; C:\Python27\ArcGIS10.4`.. if the path `C:\Python27\ArcGIS10.4` exists and has a python.exe inside it, there is just NO way you could get this error... –  Apr 27 '17 at 20:26
  • However, I can go to the respective directories and type just "python" to run it – pnkjmndhl Apr 27 '17 at 20:27
  • The only other alternative I can see is that windows might be viewing `ArcGIS10.4` as a file because of the period.. –  Apr 27 '17 at 20:27
  • That is why I said the path _must_ be defective somehow... bec ause you can run it from the location. –  Apr 27 '17 at 20:28
  • You should cut and paste the __whole__ path (not just type part of it) for us to look at. Not to be pedantic about it, but I see typos all the time that can't be caught because the asker is posting something different than really exists on his machine.. For instance on this recently: http://stackoverflow.com/questions/43599036/os-path-isfile-isnt-working-as-expected –  Apr 27 '17 at 20:33
  • Since you are running from a prompt you may want to see what cmd.exe thinks the Path is: `echo %PATH%`... if the solution below does not fix it. –  Apr 27 '17 at 21:11

1 Answers1

1

There appears to be formatting issues in the last portion of your path.

;C:\cygnus\cygwin-b20\H-i586-cygwin32\bin; C:\Python36;C:\Python27\ArcGIS10.4

There is a space that should not be here:

; C:\Python36

If removing the space does not correct the problem, then, after removing the space, I would try these things also:

1) change the order some (do this carefully to avoid introducing new errors): ;C:\Python27\ArcGIS10.4;C:\cygnus\cygwin-b20\H-i586-cygwin32\bin;C:\Python36

2) or possibly, adding semicolon to the end: ;C:\cygnus\cygwin-b20\H-i586-cygwin32\bin;C:\Python36;C:\Python27\ArcGIS10.4;

3) You could prepend the path to the beginning (and not the end):

C:\Python27\ArcGIS10.4;C:\Program Files (x86)\Intel\iCLS Client\;C:\Program Files\Intel\iCLS Client\;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\Common Files\Lenovo;C:\SWTOOLS\ReadyApps;C:\Program Files\SASHome\x86\Secure\ccme4;C:\Program Files\SASHome\Secure\ccme4;C:\Program Files (x86)\Intel\UCRT\;C:\Program Files\Intel\UCRT\;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files\Intel\Intel(R) Management Engine Components\IPT;C:\cygnus\cygwin-b20\H-i586-cygwin32\bin; C:\Python36

4) LAST RESORT (I question if this would need to be done or would even work):

Put the actual C:\Python27\ArcGIS10.4\Python.exe in the path somewhere...

  • I prepended python2 and removed the spaces and it worked. I did not add .exe in the end though. Actually I copied all the path to notepad and replaced all the spaces before and after semicolon with nospaces. Thanks. – pnkjmndhl Apr 27 '17 at 21:37
  • This is how it looks like now: C:\Python27\ArcGIS10.4;....all the other paths;C:\Python36; – pnkjmndhl Apr 27 '17 at 21:40
  • You are welcome... I ran into this stuff a few years ago on my Win machines. I ended up having to pre-pend, but maybe I had similar error then too.. I was just curious if it will work _wiithout_ the prepend if the space is gone... –  Apr 27 '17 at 21:40