Im using a scientific linux on a remote machine. I tried to install python 2.7 on it. After that the yum and some other python packages are not working (it says "no module named yum"). I searched it online and it seems I should not have touched the system python as it breaks some of the system tools. Is there a way to reinstall the previous python (which was 2.6). I already tried to install python 2.6 by downloading the package but still yum is not working.
Once you get your system back to normal, add Python 2.7 as a Software Collection - it installs "along side" the original Python 2.6 rather than replace it so both are available without collision. Get 2.7 and others from softwarecollections.org.
I use python 2.7 and have the following packages installed:
distribute
decorator
*matplotlib
memory-profiler
networkx
*numpy
Pillow
pip
py2exe
PyAudio
*PyBluez
*pygame
pyglet
*PyInstaller
pyparsing
*pyserial
python-dateutil
pytz
pywin32
requests
scikit-learn
*scipy
setuptools
six
The ones marked with a * are critical.
I want to move to python 3.5, abandoning 2.7 completely (don't want to have both).
Can I do that while still keeping my old packages or do I have to install everything from scratch?
Are there any reasons I shouldn't move to py 3.5 from 2.7?
Should I move first to 3.3/3.4 or just straight to 3.5?
I'm not using a virtualenv because I'm not very familiar with that. Should I?
UPDATE: Follow-up.
I can just make a list of the packages I have and then manually install all of them.
How do I go about installing 3.5 and uninstalling 2.7?
Do I remove 2.7 first then install 3.5 or have them both simultaneously (will this create any issue?) then remove 2.7?
I mainly use python for numpy, bluetooth, serial, OpenCV, OpenGL. I intend to foray into a bit of web too later. I don't have any issue with syntax or method change. I was previously holding out for pyinstaller but that too has been recently ported to 3.5.
Just realized after switching.
Don't install python 3.5 if you want OpenCV to work. It's not yet built for that and some functions don't work.
You will need to reinstall all your packages. You should check that all those packages are available for Python 3. (From your question it sounds like you may have already done this, but not totally sure.)
It would be wise to test how things go with Python 3 before completely abandoning Python 2. You can do this by installing the two side-by-side, or by installing Python 3 in a virtual machine or some such thing. If you have existing code you want to keep using, you definitely want to test it to make sure everything runs smoothly on Python 3.
There is likely no reason to go to 3.3/3.4. Just go straight to 3.5.
Virtualenv can definitely be useful for setting up different Python environments on the same computer. However, you'll still need to install Python 3 before you can use it in a virtualenv.
Moving packages is bad idea, it is safier to reinstall them using pip:
Use pip freeze > requirements.txt. It will store all packages and versions in file
Install Python 3.5
Run pip install -r requirements.txt. It will install same packages on your python3.5
Run all tests against this Python to make sure your app still works as expected
The only reason to stay with 2.7 is incompatible code: if your code or one of your packages does not work on Py3K.
Virtualenv is useful tool, any python developer should know how to use it.
I'm calling on psycopg2 with
import psycopg2
I get the std error
ImportError: No module named psycopg2
I installed my copy with macports, so I'm curious why it wouldn't work because all of the dependencies should be downloaded as well.
I don't have any experience with Postgresql, nor this module, so I don't know what could be going wrong. Fact is, another project I'm trying to get built calls upon it, so if I could avoid using this I would. :)
I'm sure that postgresql is installed, but that has little to do with the fact that my installation can't find psycopg2. Any suggestinos would be appreciated.
$ which python
reveals
/Library/Frameworks/Python.framework/Versions/Current/bin/python
and
$ python --version
reveals
Python 2.7.3 -- EPD_free 7.3-2 (32-bit)
I don't necessarily want the version of EPD_free, but I had to install it for (somewhat) unrelated reasons.
MacPorts installs its own version of Python alongside Apple's version. You can manage the active version of Python (the one that gets run when you type in python at the command line or by /usr/bin/env) by using the port select command. See this question.
As you can see by reading my other thread today here, I'm having some troubles upgrading Python.
At the moment I have Python 2.4 with Django installed on a CentOS machine. However I've recently deployed an application that requires 2.5 which has resulted in me installing that and getting into a whole load of mess. My original assumption was that I could direct Django to a different Python version, however as S.Lott informed me, I had it backwards... you attach Django to Python, not the other way round. Which means I currently have: Python 2.4 with Django and Python 2.5.
I've tried a few things so far to no avail. The first idea being an easy_install which would put Django onto the Python 2.5 (So I'd have 2 versions of python with seperate Djangos). Therefore I went into 2.5's directory and did that, which then allowed me to find out that it had just reinstalls it on 2.4, not 2.5. Therefore first question is How do I direct easy_install to Python 2.5, not 2.4?
Is there no way to just hit 'upgrade' and for a full update to occur? I know this may be asking for much, however it just seems like so much hassle and I'm surprised I can't find anyone else complaining. Any help would be greatly appreciated.
I don't know anything about CentOS, but if you have multiple Python version installed and you wan't to install packages using easy_install, you just need to call it with the corresponding Python interpreter. This should install the packing into the site-package directory of Python 2.5:
# /path/to/python-2.5 easy_install Django
assuming your python2.5 interpreter lives in /usr/bin/python2.5, you can install setuptools for python2.5 as such:
curl -O http://peak.telecommunity.com/dist/ez_setup.py
sudo /usr/bin/python2.5 ez_setup.py
Among other things, this installs an "easy_install-2.5" script in your $PATH (check the output of the above command).
Now you have two easy_install scripts: one for python 2.4 ("easy_install") and one for python 2.5 ("easy_install-2.5").
To install Django for your python2.5, use
sudo easy_install-2.5 django
That's it!
easy_install is a shell script the first line of which tells it where python is installed (I am on OSX so can't say exactly what your directories will be )
So you could copy easy_install and change the first line to point to 2.5. (or do as Heas suggests)
Althernatively when you installed python 2.5 there might be a file easy_install-2.5 with the correct python (again these were installed for me under OSX so might be a special version)
You don't need to 'install' Django at all, it just needs to live on the Pythonpath somewhere. Assuming it's currently in the Python2.4 site-packages directory, you can just move it to the 2.5 one:
sudo mv /usr/lib/python2.4/site-packages/django /usr/lib/python2.5/site-packages/django
or whatever the correct path is for CentOS.
However, as I noted on your other question, this won't necessarily help - S.Lott was unfortunately misleading in his answer. To serve Django via modpython or modwsgi with a new Python version, you'll need to recompile those extensions or download packages versions precompiled with Python 2.5.
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.