When you have two versions of Python installed on the same computer, in general they coexist well side by side, if installed correctly. In the case of Windows, there are a few things to consider:
A separate registry entry will be created for each of them (ex.: HKEY_LOCAL_MACHINE \ SOFTWARE \ Python \ PythonCore \ 2.7
). I think that this goes even to smaller versions (2.6
vs. 2.7
), but I’m not sure.
Inside that entrance is a key PythonPath
showing where Python is installed. If possible, check this (via regedit
) and make sure that the version you are trying to run is accessible (if it is inside the home administrator folder, you will probably only be able to access it if you run the system as an administrator).
Sometimes one of them will end up in the environment variable PATH
- to allow you to run Python by simply typing python
instead of the full path to the executable. It may be that the wrong version is in the path, and your system is calling it instead of the correct version.
Also, if your system is a Django site/application deployed via Apache, it is important that Apache finds the correct version of python. From what you described, before when there was only one version worked well, but then when the other one was installed stopped working. This strongly suggests that the second version overwritten/gained precedence in the PATH
and so Apache is trying to use it instead of the old.
The most common form of Python/Apache integration is via mod_wsgi
. It is also possible to do so through the obsolete mod_python
and, in the case of Django, in some other ways also (ex.: FastCGI
). Find out which one your project is using, and look for the information needed to specify a python among several. In mod_wsgi
, for example, it is through the property WSGIPythonExecutable
. It must be set in the Apache settings file. Maybe your mistake has something to do with WSGIPythonEggs
instead (the error message spoke of something involving the "Egg cache"). Other settings that may be useful are: WSGIPythonPath
and WSGIPythonHome
(in doubt, seven of them, according to the documentation).
Updating: I just remembered that the support for mod_wsgi
in Windows is weak... From what I read in the documentation linked above, most of these properties are not well supported in this environment. If that’s the case, I’m afraid your only way out is to actually install a single version of Python...
Finally, if the problem is not in Apache, but in the tool you are using to debug pydev
, will need to see in her settings how to specify the correct version to be used. When to do so, I’m afraid I can’t help...
When did this error occur? Were you trying to install something? Or was it while running some other program? Please edit your question by clarifying the context in which this error occurred.
– mgibsonbr
I don’t know how to answer you, even with the new information ("compile the project"? that I know python doesn’t compile...), but I can already get some idea of what might be happening: 1) maybe you are running the wrong python; if you - or some other code indirectly started - are using python
python.exe
who is in thePATH
, this may not be the same Python you want to run. Another option is something involvingPYTHONPATH
. 2) If the problem is not this, and Python is even the correct one, you should have it installed as an administrator, not as an ordinary user.– mgibsonbr
Where can I find this path ? I’m layman in python and I’m picking up a system that another programmer left behind.. the system uses Django
– Wisner Oliveira
Another option - if I’m interpreting the error message correctly - is that you installed a binary to interface python with mysql in administrator mode, and now you’re trying to execute a code that uses this binary in common user mode. P.S. The
PATH
is a Windows environment variable. How to find it depends on the windows version, but if you type in the consoleecho %path%
you can see its value. P.P.S. Hardly the problem is in Django, but it tells me how you are running? (runserver
or via external webserver, e.g. apache)– mgibsonbr
So. the system is on top of python27 I am debugging with pydev ... via apache ... this error started occurring after installing python 2.6 on the computer
– Wisner Oliveira
ih, I don’t know anything about pydev... :( I’ll write a generic response, so you can take the situation, and who knows how to guide in the search for a solution. If not, the way will be to wait for someone who is familiar with this tool to come here and answer.
– mgibsonbr