I read here that
On Windows, your Python version must match the version used to compile Mercurial. Otherwise, you'll get "Invalid Magic Number" errors when trying to run the CGI. The pre-compiled Windows binaries for Mercurial 1.0.x, 1.1.x, 1.2.x and 1.3.x were compiled with Python 2.5.
I looked online but I dont see a lookup table for this information.
Where can I find it?
If you're on Windows you want to install TortoiseHG. It provides the full Mercurial command line, a GUI with Windows shell integration, and the right version of Python all compiled in together.
The various HG installation packages have the required Python version in their name. You can also look it up in the release notes for the package.
Related
I want to plot few graphs with matplotlib and I have a windows machine Firstly I need to install, so I download the file from http://matplotlib.org/downloads.html . Well, when I tried to run, it throws a pop up saying it failed to find the version 3.4 in registry. This is a bit strange because my python version is 3.4.1.
Of course, I did search through the forum. I happened to look into numpy python 3.4.1 installation: Python 3.4 not found in registry which is same as my problem. but my first question:
1) The matplotlib official page gives me a direct link to install ".exe" for windows with python version 3.4. If this is true then why this problem should occur in the first place.
2) My second question, how one can actually find whether the downloading package version is the right match for the current python version installed on local PC.
The windows .exe installer should work for all sub-versions of a given Python installation, this means that if you use the 3.4 installer it should work for 3.4.0, 3.4.1, and 3.4.2.
You need to check that you are using the correct version of the installer, 32-bit or 64-bit. The installer should match the Python version you are using, which may or may not match your system version. This is to say that if you had a 64-bit system and used 32-bit Python, you should use the 32-bit installer.
If it still doesn't work, I'd suggest you re-install Python and try again, it's possible that something has messed with your registry settings.
Originally I thought that the sub-version mattered, but in fact it does not. I raised an issue with matplotlib here and was corrected by Christoph Gohlke who maintains the .exe installations.
Incidentally (for someone reading this in the future as you know yours) if you need to find your current Python version you can simply type python -V in the command line and it'll return the details, for example mine returns:
Python 3.4.0
I had the same problem installing matplotlib-1.4.3.win-amd64-py3.4.exe on python 3.4.3: version 3.4 not found in registry. Looking in the registry under HKEY_LOCAL_MACHINE\SOFTWARE\ there was no Python key, so matplotlib is right.
Further searching I found this SO article, Installing SetupTools on 64-bit Windows, that provided a registry script to add the necessary keys for Python 2.7. I modified the script for 3.4 and added the keys to the registry. Install of matplotlib then completed successfully. It seems the registry keys didn't get added when I installed Python 3.4.3 (sub-installer that installs registry keys is invoked at user privilege level??).
The modified registry key file I used. Save it to a text file with a .reg extension.
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Python]
[HKEY_LOCAL_MACHINE\SOFTWARE\Python\PythonCore]
[HKEY_LOCAL_MACHINE\SOFTWARE\Python\PythonCore\3.4]
[HKEY_LOCAL_MACHINE\SOFTWARE\Python\PythonCore\3.4\Help]
[HKEY_LOCAL_MACHINE\SOFTWARE\Python\PythonCore\3.4\Help\Main Python Documentation]
#="C:\\Python34\\Doc\\python343.chm"
[HKEY_LOCAL_MACHINE\SOFTWARE\Python\PythonCore\3.4\InstallPath]
#="C:\\Python34\\"
[HKEY_LOCAL_MACHINE\SOFTWARE\Python\PythonCore\3.4\InstallPath\InstallGroup]
#="Python 3.4"
[HKEY_LOCAL_MACHINE\SOFTWARE\Python\PythonCore\3.4\Modules]
[HKEY_LOCAL_MACHINE\SOFTWARE\Python\PythonCore\3.4\PythonPath]
#="C:\\Python34\\Lib;C:\\Python34\\DLLs;C:\\Python34\\Lib\\lib-tk"
Then double click the .reg file to add the registry.
I had this problem with Python3.4.2 and went back and did a reinstall. This time I paid attention to what I was doing. While installing Python3.4.2 (or 2.7) a list of options popup. The last item on the list of options is "Add Python to path". On my installation this option was marked with an X and I assume it was on the first installation. I removed the X and continued the install of Python. When I installed numpy, it found Python in the registry and loaded okay.
Open regedit.
Find python in HKEY_LOCAL_MACHINE.
Export it to some location on your hard drive.
Open the exported file in any editor.
Replace all HKEY_LOCAL_MACHINE with HKEY_CURRENT_USER and save
the file.
Now just double click on the .reg file to add this key to registry.
If you go back to the registry using regedit, you will find python in
HKEY_CURRENT_USER as well.
I really wish 'pip install numpy' worked just like it did for python 2.7.
I need to support some software that is using an old Python version (2.4). So I have downloaded and compiled Python 2.4 and installed it in a virtualenv. So far, all OK and normal procedure.
But the software is trying to import an rpm module. And I cannot find a source for that module (it is not part of the standard Python library, afaict).
Typically, once the virtualenv is enabled (source env/bin/activate) I can install required software using easy_install. But easy_install rpm is failing to find anything. There is a pyrpm module, but it is not the same thing (it installs a module called "pyrpm"). And google searches are useless, as they all link to articles on how to build rpms...
If I were using the system python (on Ubuntu) I could install the python-rpm package. But that is for Python 2.7. How do I install the equivalent for Python 2.4?
[My impression is that the rpm libraries, used by many Linux systems, include a Python library, which is packaged as python-dev by the distro. But I can't see how to access that for an arbitrary python version.]
I AM NOT LOOKING FOR AN RPM THAT CONTAINS PYTHON 2.4. I AM LOOKING FOR A MODULE NAMED rpm THAT IS USED BY SOFTWARE WRITTEN FOR PYTHON 2.4.
It's right there, in the python-rpm RPM package:
http://rpmfind.net/linux/rpm2html/search.php?query=python-rpm
You will probably want to download the package contents, extract them, and then use
python setup.py install
From your active environment.
Of course, as it's pre compiled, you might have trouble getting the C extension to run.
I'm not familiar enough with RPM's to know whether you can get the source from there.
No guarantees the package will work with your python version though.
there's no simple way to do this; the python library is part of the system rpm package and interfaces to C code, so is closely tied to the rpm package installed on your machine.
instead, it's much simpler to install an old OS in a VM (eg CentOS 5) that uses Python 2.4. then everything is consistent and works.
the sources for the rpm module can be found here: http://www.rpm.org/wiki/Download
After you download the wanted version read and follow the INSTALL instructions in order to compile it on your target OS. Afterwards make sure you add the correct path to the 'site-packages' folder the installation chose into your PYTHONPATH environment variable.
To test start your python interpreter and run 'import rpm'
HTH,
Ran
I'm looking at two different guides for Windows HgWeb installation on IIS. The first from mercurial developers says:
On Windows, your Python version must
match the version used to compile
Mercurial. Otherwise, you'll get
"Invalid Magic Number" errors when
trying to run the CGI.
The second guide says:
Don’t waste time monkeying around with
the installers. You need a version of
Mercurial matching your Python install
so get the source code!
This is all great, except nobody wants to tell you how to match versions of Python and Mercurial. I see no guide that gives a map correlating version numbers. That is my primary need. For example, I'm using Mercurial 1.9. I have no idea what version of Python goes with that. The second guide says my version of PyWin32 must match as well. Great.
If the version-match info is not available online, is there a command I can issue to Hg that will dump all this info on me?
In the mean time, I've found that I can't build the Mercurial source code (is this because I don't have a properly matching version of Python?).
HgWeb
For HgWeb, this Mercurial download page recommends using the version that installs Mercurial as python modules, requiring Python 2.6.
From that, you would select a build of PyWin32 and choose the download for Python 2.6, as they build it for several versions.
Both decisions also have 32bit and 64bit versions.
Building
The main Mercurial download page hints that Python 2.4 through 2.7 are supported, so you might try building with 2.6 or 2.7 if you still wish to build it yourself. The wiki page for building on Windows is dated, mentioning Mercurial 1.3, but also mentions Python 2.6.
I've been trying to connect opencv and python in both Ubuntu and Windows XP. I've failed on both.
I've read many webpages and threads about "how to install" it but none has worked (the worst part is that they all say kind of the same).
Steps (windows xp):
Installed Python 2.7 by default (works perfectly)
Installed PIL and cx_Freeze (may they
create a conflict? I don't think so
:s)
Installed Opencv 2.2 by default
(OpenCV-2.2.0-win32-vs2010.exe) and
it isn't recognized inside a py nor
as import opencv.cv nor using the
cookbook way, import cv (I skipped
the visual studio steps since I'll
use it with python)
Checked path (it's ok, it has the
Opencv2.2\bin thing)
Rechecked webpages and stuff
Steps (ubuntu):
Had python working
sudo apt-get install, cmake, make,
sudo make install, etcetc (from the
tutorials)
same thing... module not recognized
Please can you help?
Update:
I managed to install it and have it recognized by the system (I used http://www.lfd.uci.edu/~gohlke/pythonlibs/#opencv and it worked perfectly after that).
The problem now is that it crashes when I try to use CaptureFromFile. Someone else has reported it 3 days ago so now I wait.
I'll check the other wrappers, maybe one of them will work.
For windows see my web page: http://www.modernmind.org/wiki/OpenCV
For Ubuntu you should just need to apt-get install python-dev then generate the make files with Cmake, build it and then make install. In order to build the python bindings you need to have the python header files on your system and you probably don't. When you run configure in Cmake make sure that you don't see any messages at the top about PYTHON_INCLUDE not being defined.
To access a library it needs a Python library installed in the Python version you are using. From what you write above it seems to me that you install OpenCV in general, but that you don't specifically install the Python library. This is why it doesn't work.
I'm not sure how to install the Python wrappers, and the OpenCV documentation is a bit sparse on that info. But if you did build them (and that needs to be turned on explicitly, says the docs) they seem to end up in opencv/release/lib .
Look at "Testing Python wrappers" on http://opencv.willowgarage.com/wiki/InstallGuide
If there is still no luck, there is a bunch of alternative Python wrappers available: http://pypi.python.org/pypi?%3Aaction=search&term=opencv&submit=search
Maybe they are better documented.
I am finding it difficult to use MySQL with Python in my windows system.
I am currently using Python 2.6. I have tried to compile MySQL-python-1.2.3b1 (which is supposed to work for Python 2.6 ?) source code using the provided setup scripts. The setup script runs and it doesn't report any error but it doesn't generate _mysql module.
I have also tried setting up MySQL for Python 2.5 with out success. The problem with using 2.5 is that Python 2.5 is compiled with visual studio 2003 (I installed it using the provided binaries). I have visual studio 2005 on my windows system. Hence setuptools fails to generate _mysql module.
Any help ?
Download page for python-mysqldb. The page includes binaries for 32 and 64 bit versions of for Python 2.5, 2.6 and 2.7.
There's also discussion on getting rid of the deprecation warning.
UPDATE: This is an old answer. Currently, I would recommend using PyMySQL. It's pure python, so it supports all OSes equally, it's almost a drop-in replacement for mysqldb, and it also works with python 3. The best way to install it is using pip. You can install it from here (more instructions here), and then run:
pip install pymysql
This may read like your grandpa givin advice, but all answers here did not mention the best way: go nd install ActivePython instead of python.org windows binaries. I was really wondering for a long time why Python development on windows was such a pita - until I installed activestate python. I am not affiliated with them. It is just the plain truth. Write it on every wall: Python development on Windows = ActiveState!
you then just pypm install mysql-python and everything works smoothly. no compile orgy. no strange errors. no terror. Just start coding and doing real work after five minutes.
This is the only way to go on windows. Really.
As Python newbie learning the Python ecosystem I've just completed this.
Install setuptools instructions
Install MySQL 5.1. Download the 97.6MB MSI from here You can't use the essentials version because it doesnt contain the C libraries.
Be sure to select a custom install, and mark the development tools / libraries for installation as that is not done by default. This is needed to get the C header files.
You can verify you have done this correctly by looking in your install directory for a folder named "include". E.G C:\Program Files\MySQL\MySQL Server 5.1\include. It should have a whole bunch of .h files.
Install Microsoft Visual Studio C++ Express 2008 from here This is needed to get a C compiler.
Open up a command line as administrator (right click on the Cmd shortcut and then "run as administrator". Be sure to open a fresh window after you have installed those things or your path won't be updated and the install will still fail.
From the command prompt:
easy_install -b C:\temp\sometempdir mysql-python
That will fail - which is OK.
Now open site.cfg in your temp directory C:\temp\sometempdir and edit the "registry_key" setting to:
registry_key = SOFTWARE\MySQL AB\MySQL Server 5.1
now CD into your temp dir and:
python setup.py clean
python setup.py install
You should be ready to rock!
Here is a super simple script to start off learning the Python DB API for you - if you need it.
I found a location were one person had successfully built mysql for python2.6, sharing the link, http://www.technicalbard.com/files/MySQL-python-1.2.2.win32-py2.6.exe
...you might see a warning while import MySQLdb which is fine and that won’t hurt anything,
C:\Python26\lib\site-packages\MySQLdb__init__.py:34: DeprecationWarning: the sets module is deprecated
from sets import ImmutableSet
What about pymysql? It's pure Python, and I've used it on Windows with considerable success, bypassing the difficulties of compiling and installing mysql-python.
You're not the only person having problems with Python 2.6 and MySQL (http://blog.contriving.net/2009/03/04/using-python-26-mysql-on-windows-is-nearly-impossible/). Here's an explanation how it should run under Python 2.5 http://i.justrealized.com/2008/04/08/how-to-install-python-and-django-in-windows-vista/
Good luck
The precompiled binaries on http://www.lfd.uci.edu/~gohlke/pythonlibs/#mysql-python is just worked for me.
Open MySQL_python-1.2.5-cp27-none-win_amd64.whl file with zip
extractor program.
Copy the contents to
C:\Python27\Lib\site-packages\
On Python 3.4 I've installed mysqlclient from http://www.lfd.uci.edu/~gohlke/pythonlibs/ with pip install mysqlclient and it's working.
You can try to use myPySQL. It's really easy to use; no compilation for windows, and even if you need to compile it for any reason, you only need Python and Visual C installed (not mysql).
http://code.google.com/p/mypysql/
Good luck
There are Windows binaries for MySQL-Python (2.4 & 2.5) available on Sourceforge. Have you tried those?
Because I am running python in a (pylons/pyramid) virtualenv, I could not run the binary installers (helpfully) linked to previously.
I had problems following the steps with Willie's answer, but I determined that the problem is (probably) that I am running windows 7 x64 install, which puts the registry key for mysql in a slightly different location, specifically in my case (note: I am running version 5.5) in: "HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\MySQL AB\MySQL Server 5.5".
HOWEVER, "HKEY_LOCAL_MACHINE\" cannot be included in the path or it will fail.
Also, I had to do a restart between steps 3 and 4.
After working through all of this, IMO it would have been smarter to run the entire python dev environment from cygwin.
If you are looking for Python 3.2 this seems the best solution I found so far
for Python 2.4 - 3.2 PyMySQL
for Python 2.3 - 2.6 MySQL for Python
Source: http://wiki.python.org/moin/MySQL
You might want to also consider making use of Cygwin, it has mysql python libraries in the repository.
You can also use pyodbc with the MySQL Connector/ODBC to use MySQL on Windows. Unixodbc is also available to make the code compatible on Linux. Pyodbc uses the standard Python DB API 2.0 so if you stick with that switching between MySQL/PostgreSQL/SQLite/ODBC/JDBC drivers etc. should be relatively painless.
upvoted itsadok's answer because it led me to the installation for python 2.7 as well, which is located here: http://www.codegood.com/archives/129
Got sick of the installation troubles with MySQLdb and tried pymysql instead.
Easy setup;
git clone https://github.com/petehunt/PyMySQL.git
python setup.py install
And APIs are pretty much the same.