I am having problems getting python/django to connect to a MySQL database. The error message is basically "Error Loading MySQLDb module: No module named MySQLDb".
This is a fresh install right off python.org, so I assumed that it would have the MySQLDb module included, but it does not seem to. I also can't seem to find the module or how to install it, except in some sleazy looking parts of the net.
Is there a central point for getting this module? Why isn't it in the standard install? Can someone point me to a tutorial or some such to get this module installed?
Newbie in python, MySQL and Django.
Thanks for help.
I believe http://pypi.python.org/pypi/MySQL-python/ is the Python module you need. In general, when looking for Python modules, http://pypi.python.org/ is where you should start (people will refer to it as either PyPI or "the cheese shop." If setuptools is installed (it may be already) then you can run easy_install MySQL-python.
As far as MySQL is concerned, you'll need to install that separately from a likely-looking package on http://dev.mysql.com/downloads/mysql/.
this is how i handled the issue on Fedora13:
you can get the module here: http://sourceforge.net/projects/mysql-python/
download to a convenient directory
read the README file
build the module, according to the instructions in the README, keeping in mind to use the version of python you are planning to use as an interpreter (2.6 for me). if there are more than one version of python, simply using 'python' will probably alias you into a particular version, which might not be the one you want.
after the build is complete, the .egg file will have been created and landed in a 'site-packages' directory associated with the version of python which was used for the build.
then, ensure that the .egg file created (you can see the install path in the output from the install) is placed on your PYTHONPATH
that did it for me, anyhoo...
good luck!
JR
Related
I'm working with Concept Drift, but when trying to run my code i get this error
"ImportError: No module named detector_classifier" been trying to install the module with pip install, but all i get is no match found. Anyone had this problem before?
Before you can import third party libraries, you need to install first. If you could not install with pip install, it means it's not published on PyPI. You need to install directly from source where you found code/module for Concept Drift or detector_classifier, or whatever you're trying to use.
I think a little more information might help. Which python version and which pip version are you using? I just googled "detector_classifier" and couldn't find anything. What library does "detector_classifier" belong to?
Without much background to go off of, I would recommended making sure you have updated pip. Depending on what operating system you're using, your configuration might need some tinkering so your system knows where to look.
I am trying to find a way to include a library in a Ubuntu/Python/PyGtk application even though It is not included in the stock python enviornment and I can't add it as a dependency in my setup.py file. The library is called pygal and does have a PIP package (No available .deb or ppa) but I was looking for a way to include it in my application. I would think I could just include the source .py files to the library but I am unsure of how to go about including it in my code. Pygal also requires the lxml python library. I can install it via pip on my machine and it works fine but didn't know if there was anyway to automate or include this in my .deb package's setup.py file. Any help or advice would be greatly appreciated.
I think this should work though I'm not sure.
You put the folder with the name pygal from the pygal egg in your application directory. You can take it from your python installation - it should have this path:
/usr/local/lib/python2.7/dist-packages/pygal-0.13.0-py2.7.egg/pygal
or if you use python 3.1
/usr/local/lib/python3.1/dist-packages/pygal-0.13.0-py3.1.egg/pygal
or download it from pipy.
You can use it like any python library:
from pygal import *
I've actually figured out how to package this as a *deb file that I can include in my future PPA (or possibly submit to the community) that will (hopefully) cleanly install the python package on the system. I found a great write up in the Debian wiki that actually doesn't seem cryptic to a newbie like myself, oddly enough.
http://wiki.debian.org/Python/Packaging#Example_1:_Python_extension
tl;dr
I accidentally deleted my Python installation’s site.py file. Now, when trying to start Python, it complains,
ImportError: Couldn't find the real 'site' module
I tried downloading a site.py from setuptools but this results in an infinite recursion in the __boot method around the statement imp.load_module('site',stream,path,descr) (line 37).
Is there a way to fix this without reinstalling Python? What is the site.py file supposed to do?
Some background information:
This is on a Linux server with a custom Python installation in my home directory (~/nfs, to be precise). There are other Python installations on the server (not mine – it’s a mess!) but $PATH and $PYTHONPATH are set up in such a way as to find my installation first.
As to why I deleted the site.py file: I tried executing a setuptools setup.py script and the script told me to delete the file because it “was not created by setuptools”. I foolishly complied.
I suspect that this original error message was caused by the fact that the setuptools implementation is not mine.
The site module sets up your python module search path and some other things. It is somewhat crucial to the normal operation of python.
You can download a new copy from the python source repository:
For python 2.7
For python 3.2
For other python versions, generally the URL is http://hg.python.org/cpython/file/*major*.*minor*/Lib/site.py for the correct tagged version, then select the raw link in the left-hand menu.
If you installed python from a linux distribution package on Ubuntu or Debian, then this file has been customized and you'll need to re-install the appropriate python-minimal package.
I need to use the Sybase Python module but our SA's won't install because it's not in the repo's. I've downloaded it and placed it on the box and would just like to 'import' or 'include' the module without installing it first. - Is this possible? From the looks of it (Sybase ASE) it needs some type of compilation before use. Is it possible for this type of work around?
If you can get Sybase to use a virtual environment (I know nothing about Sybase, sorry), perhaps you could install the module using virtualenv, which generally doesn't require root access or SA approval.
From the sybase documentation it looks like compilation is required, and Google tells me that it's not available in the easy_install repos either.
It may be easier to do a little social engineering (cookies anyone?) to get the modules installed for you. I don't know what your work environment is like, but if you really need the python Sybase module to do your job, either 1) the SA's should be installing it anyway, or 2) you need to be using something different.
You could always try writing a python script that does the d/l and install automagically and give it to the SAs so they don't have to worry about the "difficulty" of doing something besides apt-getting.
I don't know about the virtual environments, though - that might be an ideal avenue.
Assuming you meet the prerequisites for compiling, untarring it and then running:
python setup.py build_ext
should produce a sybasect shared object. Copying this file and the Sybase.py file somwhere onto PYTHONPATH might just do it for you.
I am implementing the reddit.com source code on ubuntu karmic 9.10.
I have followed all the steps and in one step where i am using paster command it throws an error.
$paster shell example.ini
File "/usr/local/lib/python2.6/dist-packages/Pylons-0.9.6.2-
py2.6.egg/pylons/middleware.py", line 11, in
from webhelpers.rails.asset_tag import javascript_path
ImportError: No module named rails.asset_tag
I have checked for the version for webhelpers, its the latest installed.
Could anybody tell me that by installing another version of webhelpers will solve this problem?
Or Shall i modify the code?
Its a reddit.com source code written in python, using pylons framework.
I am unable to decide that whether by installing any previous version of webhelpers helps or shall i modify the code.
If there is anybody who have implemented the reddit.com website please help me or suggest me the best way.
thanks
SIA
You need to ensure that all the libraries needed by your Reddit clone are on Python's module search path. There are a lot of different ways to accomplish this. The easiest is probably to just use setuptools' easy_install command to install them (though this is my own personal least favorite way to install Python libraries, and also opens new cans of worms in the form of "Why not use distribute or pip instead?").
The next easiest way is probably to download and unpack the source code for the libraries you need and either a) setup.py install them or b) add their directories to your $PYTHONPATH or sys.path variables.
The documentation linked above has more info on how to control the module search path.