Reputation: 583
I have three Python environments across two different interpreters. The first is the basic Python27 in my c:. The second is an Anaconda interpreter with its own environment and another environment in it's \envs\ directory. I have directed my PYTHONPATH variable to point to the Anaconda interpreter not in the \envs\ folder.
I also have my PATH variable set to the scripts directory from that environment
However, when I run Django, I get a message about a discrepancy in versions. I think this results from the fact that Django is using the interpreter in my C:\ directory, Python27. When I echo my PATH environment variable in cmd, this is what I see:
C:\Program Files (x86)\ActiveState Komodo Edit 10\;C:\Program Files (x86)\ActiveState Komodo IDE 10\;
C:\Program Files\MATLAB\R2014a\bin\win64;
C:\ProgramData\Oracle\Java\javapath;
c:\Program Files (x86)\Intel\iCLS Client\;
c:\Program Files\Intel\iCLS Client\;
C:\Windows\system32;C:\Windows;
C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;
C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Components\IPT;
C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;
C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files\Intel\WiFi\bin\;
C:\Program Files\Common Files\Intel\WirelessCommon\;C:\Program Files (x86)\IVI Foundation\VISA\WinNT\Bin;C:\Program Files\Microsoft SQL Server\110\Tools\Binn\;C:\Program Files (x86)\Microsoft SDKs\TypeScript\1.0\;
C:\Program Files\Microsoft SQL Server\120\Tools\Binn\;
**C:\Python27**;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\QuickTime\QTSystem\;C:\WINDOWS\system32\config\systemprofile\.dnx\bin;C:\Program Files\Microsoft DNX\Dnvm\;C:\Program Files\Microsoft\Web Platform Installer\;C:\Program Files (x86)\Windows Kits\10\Windows Performance Toolkit\;C:\Program Files (x86)\Skype\Phone\;
C:\Program Files\MATLAB\R2016a\runtime\win64;
C:\Program Files\MATLAB\R2016a\bin;
C:\WINDOWS\system32;
C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;
C:\Users\jackf_000\sw\FFMPEG\bin;
C:**\Users\jackf_000\sw\Anaconda2\Scripts\**;
C:\cygwin64\bin;C:\Users\jackf_000\AppData\Local\Microsoft\WindowsApps;
When I run python in cmd and import os to see the executable, I get the following output:
C:\Users\jackf_000>python
Python 2.7.9 (default, Dec 10 2014, 12:28:03) [MSC v.1500 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.executable
'C:\\Python27\\python.exe'
Why is the Python interpreter from C:\ in the PATH variable before the Anaconda one if I do not have it specified anywhere in PATH in the control panel window? And how can I specify that I want Django to look in the Anaconda environment for what it needs, or use pip to install to Django to C:\Python27? Currently, pip installs all packages to the Anaconda environment.
Upvotes: 0
Views: 395
Reputation: 140148
Because python 2.7 path is set in the system environment variable PATH. You are editing your user variables (which are bizarrely configured because they contain duplicate stuff only found in system path like C:\windows\system32
for instance)
if you type where python
you'll probably get:
C:\Python27\python.exe
(EDIT: you actually get that value, since you answered to my comment)
if you type where pip
you'll probably get:
C:\users\jackf_000\sw\anaconda2\scripts\pip.exe
which explains that pip installs package in the anaconda2 package
To get anaconda python in your path you would need to add C:\users\jackf_000\sw\anaconda2
not the scripts subdir that contain pip.
then, if you typed where python
you'll probably get:
C:\Python27\python.exe
C:\users\jackf_000\sw\anaconda2\python.exe
But that wouldn't be enough because..
The system path comes first. PATH is one special env variable that you dont override with your user profile, only append dirs to. And it's perfectly normal to have one user PATH variable and one system PATH variable.
On the other hand, let's say the system variable PYTHONPATH
does not please you, you could choose to replace it by setting a completely different one in your user variables. That would replace the paths, not append to them, unless you add ;%PYTHONPATH%
somewhere (PYTHONPATH
is a path variable, but unknown by windows, it's nothing special). And PYTHONPATH does not influence which executable will be loaded, so forget it for now.
2 solutions:
run your applications which require anaconda with a .bat file starting by the following:
set PATH=C:\users\jackf_000\sw\anaconda2;%PATH%
rem now run the command which needs anaconda python first
Upvotes: 1