Did I give a virus to my Django? manage.py disappearing - python

My Django installation is falling a part - could I have a virus?
I recently installed : https://github.com/chrisdev/django-pandas/
using pip and now very scary things are happening:
my manage.py in the root directory clears after every execution
even when I rename it something else, the starting script becomes a blank file
The admin section of the app wont run at all. I get errors
like:
[06/Feb/2015 06:27:48] "GET /admin/ HTTP/1.1" 200 4308
Exception happened during processing of request from ('127.0.0.1', 51159)
Traceback (most recent call last):
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/SocketServer.py", line 295, in _handle_request_noblock
self.process_request(request, client_address)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/SocketServer.py", line 601, in process_request
t = threading.Thread(target = self.process_request_thread,
AttributeError: 'NoneType' object has no attribute 'Thread'
What is really confusing is I had to comment out a settings line pertaining to “SessionAuthenticationMiddleware” or I get this
File "/Users/rpanos/.virtualenvs/JiraStat_Local_JB/lib/python2.7/site-packages/django/utils/module_loading.py", line 31, in import_by_path
error_prefix, module_path, class_name))
ImproperlyConfigured: Module "django.contrib.auth.middleware" does not define a "SessionAuthenticationMiddleware" attribute/class
Why would that suddenly be necessary?
If any one has any idea how these things are happening, please let me know.
I already did a pip uninstall on django-pandas but I imagine there could be some nefarious remnant doing this?
My sincere apologies if django-pandas has nothing to do with this but my django install has been working great for a year and now all is going to crap!
Just in case another package might be the issue, please see my virtual environement here:
(JiraStat_Local_JB)Rs-Mac-mini:JiraStats rXXXXs$ lssitepackages
Django-1.6.10-py2.7.egg-info lxml-3.4.0-py2.7.egg-info queuelib
OpenSSL model_utils queuelib-1.2.2-py2.7.egg-info
Scrapy-0.24.4-py2.7.egg-info numpy requests
Twisted-14.0.2-py2.7.egg-info numpy-1.9.0-py2.7.egg-info requests-2.4.3-py2.7.egg-info
_cffi_backend.so oauthlib requests_oauthlib
_markerlib oauthlib-0.6.3-py2.7.egg-info requests_oauthlib-0.4.1-py2.7.egg-info
cffi pandas scrapy
cffi-0.8.6-py2.7.egg-info pandas-0.14.1-py2.7.egg-info setuptools
cryptography pip setuptools-1.1.5-py2.7.egg-info
cryptography-0.6-py2.7.egg-info pip-1.4.1-py2.7.egg-info six-1.8.0-py2.7.egg-info
cssselect pkg_resources.py six.py
cssselect-0.9.1-py2.7.egg-info pkg_resources.pyc six.pyc
dateutil psycopg2 tlslite
django psycopg2-2.5.4-py2.7.egg-info tlslite-0.4.6-py2.7.egg-info
django_model_utils-2.2-py2.7.egg-info pyOpenSSL-0.14-py2.7.egg-info twisted
easy_install.py pycparser w3lib
easy_install.pyc pycparser-2.10-py2.7.egg-info w3lib-1.10.0-py2.7.egg-info
jira python_dateutil-2.2-py2.7.egg-info zope
jira-0.32-py2.7.egg-info pytz zope.interface-4.1.1-py2.7-nspkg.pth
lxml pytz-2014.7-py2.7.egg-info zope.interface-4.1.1-py2.7.egg-info
UPDATE
django-pandas did downgrade my Django and that solved a couple problems. Thank you Alasdair and Bernhard! However, there seems to be another issue.
I had two poorly formed packages - ones that I made by hand because I thought I knew what I was doing - when I remove them, all of the issues with the manage.py script go away. I usually trust PyCharm to do it, but these two I just copied the init files from another directory an started coding.
I have replaced and removed both of them to test this theory and its pretty solid.
Could any of you Django experts guess why a bad package would cause Django to crash AND delete its own manage.py?
It was still deleting "itself" after I re-upgraded Django.

Installing django-pandas most likely downgraded your Django installation as it explicitly requires Django < 1.7.

SessionAuthenticationMiddleware was added in Django 1.7. The traceback suggests that you may have Django 1.6 or earlier installed.

Related

Cryptic Django CMS install error - what might be causing this error?

(env) Name-MacBook-Pro-2:site_cms name$ djangocms -f -p . site_cms
Creating the project
Please wait while I install dependencies
If I am stuck for a long time, please check for connectivity / PyPi issues
Dependencies installed
Creating the project
The installation has failed.
*****************************************************************
Check documentation at https://djangocms-installer.readthedocs.io
*****************************************************************
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.7/bin/djangocms", line 11, in <module>
sys.exit(execute())
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/djangocms_installer/main.py", line 44, in execute
django.setup_database(config_data)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/djangocms_installer/django/__init__.py", line 407, in setup_database
command, env=env, stderr=subprocess.STDOUT
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/subprocess.py", line 376, in check_output
**kwargs).stdout
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/subprocess.py", line 468, in run
output=stdout, stderr=stderr)
subprocess.CalledProcessError: Command '['/Library/Frameworks/Python.framework/Versions/3.7/bin/python3.7', '-W', 'ignore', 'manage.py', 'migrate']' returned non-zero exit status 1.
I am following the instructions on this page:
http://docs.django-cms.org/en/develop/introduction/01-install.html
However I am unsure why it is not installing.
Is there anyway to get more verbose data on the error? I'm trying to google each of these lines and nothing is consistent with the issue I am having.
Could it be due to Python version?
This is on OSX - High Sierra. Do I possibly need to do something to let Django CMS connect to my database?
In case anyone else runs into this issue, or if the OP never solved it, I encountered the same issue tonight and it looks like python 3.7 is indeed the culprit.
djangocms (currently) only supports up to Django 1.11, which does not appear to support python 3.7. Django 1.11 release notes
What tipped me off was re-running the install with the --verbose option and seeing this line:
'%s=%s' % (k, v) for k, v in params.items(),
^
SyntaxError: Generator expression must be parenthesized
A quick google search appeared to confirm that this is an issue with python3.7/Django 1.11 a la stack overflow.
According to the djangocms roadmap, Divio is leading development on the next major release which will include Django 2.0 (and thus python3.7, presumably) support.
In the meantime, you'll probably have to stick with python3.6, since djangocms' docs claim support for 3.6, even though the tutorial only lists up to python3.4.
Good luck!

ModuleNotFoundError: No module named 'flask_session'

I have a simple python file that I am trying to set up to utilize sessions, when i run the file I am receiving the error below:
ModuleNotFoundError: No module named 'flask_session'
I believe I am importing the module properly, is there anything else that I can check to set this up properly?
from flask import Flask, render_template, request, session
from flask_session import Session
app = Flask(__name__)
app.config["SESSION_PERMANENT"] = False
app.config["SESSION_TYPE"] = "filesystem"
Session(app)
#app.route("/", methods=["GET", "POST"])
def index():
if session.get("notes") is None:
session["notes"] = []
if request.method == "POST":
note = request.form.get("note")
session["notes"].append(note)
return render_template("index.html", notes=notes)
Here is the traceback ( most recent call last )
File "c:\python37\lib\site-packages\flask\cli.py", line 325, in __call__
Open an interactive python shell in this frameself._flush_bg_loading_exception()
File "c:\python37\lib\site-packages\flask\cli.py", line 313, in _flush_bg_loading_exception
reraise(*exc_info)
File "c:\python37\lib\site-packages\flask\_compat.py", line 35, in reraise
raise value
File "c:\python37\lib\site-packages\flask\cli.py", line 302, in _load_app
self._load_unlocked()
File "c:\python37\lib\site-packages\flask\cli.py", line 317, in _load_unlocked
self._app = rv = self.loader()
File "c:\python37\lib\site-packages\flask\cli.py", line 372, in load_app
app = locate_app(self, import_name, name)
File "c:\python37\lib\site-packages\flask\cli.py", line 242, in locate_app
'\n\n{tb}'.format(name=module_name, tb=traceback.format_exc())
I've first encountered this problem while doing Harvard's CS50x class. I'm using Linux and I've been using Python3, as it turns out I've installed Flask-Session for Python2.
I don't know whether it also applies to Mac but I used the following instead:
$ pip3 install flask-session
Then you can check whether it's installed with pip's freeze command. After doing this my pylint in VSCode no longer gave an error.
I got the flask_session module not found a number of times and it took me 2 hours to find a fix after thousands of attempts. Well, I too visited a number of sites looking for a solution but didn't get any. I got this error while I was learning the online course cs50 web development on edx.org by Harvard and when I read the forum discussion on reddit I saw comments where they mentioned Harvard used a special server to make it work and I felt the pain of not going to Harvard but two hours later I'm screaming because I just found a solution that's no where on the internet.
You should not use from flask_session import Session
Instead use from flask_session.__init__ import Session
I cannot explain the terminology as to why we do this here but you can private message me if you want to understand why we do this. Happy Coding!
Be sure to have the extension installed:
pip install Flask-Session
oficial page with instructions
If you get the error "ModuleNotFoundError: No module named 'werkzeug.contrib'":
pip install werkzeug==0.16.0
The latest version is the 1.0.1 but only the 0.16.0 worked.
(where I found this solution) (official page)
simply goto terminal and type pip install flask_session , wait for installation, once done you are good to go. ( Also many other solutions do not work, look for red highlighted part in image. Once installed it works properly.)
I ran into the same error.
The following worked for me.
Install the extension with the following command:
$ easy_install Flask-Session
or alternatively, if you have pip installed:
$ pip install Flask-Session
I got it for windows:
There's no the library "flask_session" (--is a directory--) in your directory ...venv\Lib\site-packages (virtual environment)
You just need copy it from C:\Users\your _user\AppData\Local\Programs\Python\Python37-32\Lib\site-packages
and then paste it in venv\Lib\site-packages or where you have installed your virtual environment. Thats it and sorry for my english, greetings from Medellin Colombia.
Try to do following command instead of all go to terminal and type
$ easy_install Flask-Session
If it shows an error,use sudo before it , If it shows any error please let me know also feel free to upvote
Install the extension first using the following command $ pip install Flask-Session. You can read more on flask-session via https://pythonhosted.org/Flask-Session/
For completeness, I will share my solution:
In my case installed everything with pip3 to make it work with python 3.7, only worked with vscode after uninstalling python 2 from the system and reopening vscode.
Are you using this library? https://pythonhosted.org/Flask-Session/
The docs suggest importing it this way: from flask.ext.session import Session

How to resolve cannot import name pages (django/wagtail)

Recently I have been trying to get wagtail to work with my existing Django application. I was experiencing an error: -
ImportError: No module named wagtail
unable to load app 0 (mountpoint='') (callable not found or import error)
After much troubleshooting I managed to fix this, by copying the folder wagtail from:
/usr/local/lib/python2.7/dist-packages/
into here
/opt/django/src/
Having resolved this error, I received another about a different module, and another... each time I copied the folder from /usr/local/lib/python2.7/dist-packages/ into /opt/django/src/ and it eventually resolved the issues I was having and uWSGI started.
Now when I access the homepage of my app, I receive this error
ImportError at /
cannot import name pages
Request Method: GET
Request URL: http://example.com
Django Version: 1.9
Exception Type: ImportError
Exception Value:
cannot import name pages
Exception Location: ./wagtail/wagtailadmin/urls/__init__.py in <module>, line 4
Python Executable: /usr/local/bin/uwsgi
Python Version: 2.7.3
Python Path:
['.',
'',
'/opt/django/src',
'/root/.python',
'/opt/django/env/lib/python2.7',
'/opt/django/env/lib/python2.7/plat-linux2',
'/opt/django/env/lib/python2.7/lib-tk',
'/opt/django/env/lib/python2.7/lib-old',
'/opt/django/env/lib/python2.7/lib-dynload',
'/usr/lib/python2.7',
'/usr/lib/python2.7/plat-linux2',
'/usr/lib/python2.7/lib-tk',
'/opt/django/env/local/lib/python2.7/site-packages',
'/opt/django/env/lib/python2.7/site-packages']
I have checked the file referenced (./wagtail/wagtailadmin/urls/__init__.py) and it looks like this:
from django.conf.urls import url, include
from django.views.decorators.cache import cache_control
from wagtail.wagtailadmin.urls import pages as wagtailadmin_pages_urls
from wagtail.wagtailadmin.urls import collections as wagtailadmin_collections_urls
from wagtail.wagtailadmin.urls import password_reset as wagtailadmin_password_reset_urls
from wagtail.wagtailadmin.views import account, chooser, home, pages, tags, userbar
from wagtail.wagtailadmin.api import urls as api_urls
from wagtail.wagtailcore import hooks
from wagtail.utils.urlpatterns import decorate_urlpatterns
from wagtail.wagtailadmin.decorators import require_admin_access
The offending line is the first wagtail 'from' ...
from wagtail.wagtailadmin.urls import pages as wagtailadmin_pages_urls
How can I resolve this error?
I've ran a few tests on wagtail setup. I made each test in a fresh Ubuntu 14 install (each test in a new workspace on Cloud9 IDE).
Test 1: Straight python 2.7
sudo pip install wagtail
ERRO: error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
Comment: Lots of x86_64-linux-gnu-gcc: error: build/temp.linux-x86_64-2.7/libImaging/codec_fd.o: No such file or directory errors were output.
Didn't work.
Test 2 - Python 2.7 with virtualenv
sudo pip install virtualenv
virtualenv env
source env/bin/activate
Now from their github https://github.com/wagtail/wagtail
pip install wagtail
out: Successfully installed Django-1.10.7 Pillow-4.1.1 Unidecode-0.4.20 Willow-0.4 beautifulsoup4-4.5.3 django-modelcluster-3.1 django-taggit-0.22.1 django-treebeard-4.1.0 djangorestframework-3.6.2 html5lib-0.999999999 olefile-0.44 pytz-2017.2 requests-2.13.0 wagtail-1.9.1 webencodings-0.5.1
wagtail start mysite
cd mysite
python manage.py migrate
python manage.py createsuperuser
python manage.py runserver
I had to edit the settings/dev.py and include ALLOWED_HOSTS = ['*'] because I'm on cloud 9. Also needed the $IP:$PORT after runserver. WORKED!
Test3 - Python 3.4 with virtualenv
sudo pip3 install virtualenv
virtualenv -p python3 env
source env/bin/activate
pip install wagtail
Successfully installed Django-1.10.7 Pillow-4.1.1 Unidecode-0.4.20 Willow-0.4 beautifulsoup4-4.5.3 django-modelcluster-3.1 django-taggit-0.22.1 django-treebeard-4.1.0 djangorestframework-3.6.2 html5lib-0.999999999 olefile-0.44 pytz-2017.2 requests-2.13.0 wagtail-1.9.1 webencodings-0.5.1
Rest of the command are the same. And it WORKED!
Test 4 - Python 3.4 no virtualenv
sudo pip3 install wagtail
out: Successfully installed wagtail django-taggit requests Unidecode Django djangorestframework Pillow beautifulsoup4 Willow django-modelcluster django-treebeard olefile pytz
wagtail start mysite
python3 manage.py migrate
python3 manage.py createsuperuser
python3 manage.py runserver
EDIT: Made a mistake. Should've run with python3, not python in this case. Did it again and worked!
Conclusion: Looks that you need a virtualenv for this to work on Ubuntu 14 and python2. With python3 it works with and without virtualenv. I could not reproduce your error, but the idea is the same: it does not work because it looks for stuff in the wrong place.
Comments: There are two things you mention that I could not test:
I have been trying to get wagtail to work with my existing Django
application
With this big amount of heavy dependencies, (Pillow, Django rest, beatifullsoup and others I've never heard of) it would be strange if it worked out of the box with a previous setup. I mean, Django is a dependency for wagtail. So I would try the other way around. Start fresh with wagtail and port your code there (with python3 for the sake of the community ;) ). Also this manual copy of files is like programmers worst nightmare (at least to me). This looks like a version problem. Try to post the versions of everything involved, and the exact steps to reproduce the issue. I mean, did you pip install wagtail in the operating system that django was running?
I was having and uWSGI started.
So you have your app deployed already? This complicates things. If versions and virtualenv do not solve your problem, community needs setup details of deploy. Also you haven't mentioned your operational system.
I hope this helps! Good Luck!
I ran into the
cannot import name pages
error at:
from wagtail.wagtailadmin.urls import pages as wagtailadmin_pages_urls
while trying to deploy a wagtail app to Google App Engine and could not duplicate the problem on my local dev server.
A seemingly unrelated error that I saw only intermittently in GAE involved an import error in the PIL library. I was able to resolve BOTH errors by deleting PIL and pillow related folders from my vendored packages in my /lib directory. I had to import PIL through the app.yaml file instead due to the platform specific binary, but running pip install -t lib/ -r requirements-vendor.txt caused PIL to be installed into the lib folder as well (as a dependency of Wagtail)

Django, Mezzanine: Autodiscover error, referencing non-existent model

The Django project I'm working on was set up by someone else, prior to me working on it. It has also the Mezzanine component which I'm not familiar with; have not been needing to use it. Suddenly, I have an error which I can't figure out how to fix...
I have an app 'Dashboards' which started off without any models -- models.py was empty, sans the default from django.db import models. Today, I added a model called Banners into it, and I added the admin.py file (as I was intending to use Django's admin module for it). I may have restarted foreman throughout but I never ran any migrations on the model.
Subsequently, I decided to delete the model definitions as well as admin.py, because I decided to create a separate app to handle the specific feature I was working on. After restarting foreman, Django keeps throwing an error:
ImportError at /
No module named banners.models
Request Method: GET
Request URL: http://127.0.0.1:9000/
Django Version: 1.5.5
Exception Type: ImportError
Exception Value:
No module named banners.models
Exception Location: /home/vagrant/www/local/lib/python2.7/site-packages/django/utils/importlib.py in import_module, line 35
Python Executable: /home/vagrant/www/bin/uwsgi
Python Version: 2.7.3
Python Path:
['.',
'',
'/home/vagrant/www/src/django-experiments',
'/home/vagrant/www/src/gargoyle',
'/home/vagrant/www/src/nexus',
'/home/vagrant/www/local/lib/python2.7/site-packages/newrelic-2.6.0.5/newrelic/bootstrap',
'/home/vagrant/www/lib/python2.7',
'/home/vagrant/www/lib/python2.7/plat-linux2',
'/home/vagrant/www/lib/python2.7/lib-tk',
'/home/vagrant/www/lib/python2.7/lib-old',
'/home/vagrant/www/lib/python2.7/lib-dynload',
'/usr/lib/python2.7',
'/usr/lib/python2.7/plat-linux2',
'/usr/lib/python2.7/lib-tk',
'/home/vagrant/www/local/lib/python2.7/site-packages']
Server time: Tue, 18 Feb 2014 01:13:55 +0000
More specifically, in:
./urls.py in <module>
admin.autodiscover() ...
▶ Local vars
/home/vagrant/www/local/lib/python2.7/site-packages/mezzanine/boot/__init__.py in autodiscover
django_autodiscover(*args, **kwargs) ...
▶ Local vars
I searched all my source, definitely I'm NOT importing 'banners' anywhere. What is the proper way to completely clear it out?
If you are definitely not importing banners anywhere (a search through your codebase should confirm this), then you may have compiled python files still referencing the old stuff.
I can't reproduce exactly what causes this, but I've run into problems like this many times, specifically manifesting in cryptic urls.py import errors.
Try a good old find . -name "*.pyc" | xargs rm
As usual, be very careful with rm commands - never trust it, triple check you wrote *.pyc or have backups / version control.

How can I use Django with MySQL in MAMP stack?

I have difficulty especially in installing MySQLdb module (MySQL-python-1.2.3c1), to connect to the MySQL in MAMP stack.
I've done a number of things such as copying the mysql include directory and library (including plugin) from a fresh installation of mysql (version 5.1.47) to the one inside MAMP (version 5.1.37).
Now, the MySQLdb module build and install doesnt give me error.
The error happens when I'm calling 'import MySQLdb' from python shell (version 2.6).
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "build/bdist.macosx-10.6-universal/egg/MySQLdb/__init__.py", line 19, in <module>
File "build/bdist.macosx-10.6-universal/egg/_mysql.py", line 7, in <module>
File "build/bdist.macosx-10.6-universal/egg/_mysql.py", line 6, in __bootstrap__
ImportError: dlopen(/Users/rhenru/.python-eggs/MySQL_python-1.2.3c1-py2.6-macosx-10.6-universal.egg-tmp/_mysql.so, 2): Symbol not found: _mysql_affected_rows
Referenced from: /Users/rhenru/.python-eggs/MySQL_python-1.2.3c1-py2.6-macosx-10.6-universal.egg-tmp/_mysql.so
Expected in: flat namespace
in /Users/rhenru/.python-eggs/MySQL_python-1.2.3c1-py2.6-macosx-10.6-universal.egg-tmp/_mysql.so
Any idea, what else do I need to do to make it works?
Thanks a bunch,
Robert
=========
Add the system response after using virtualenv as suggested by Hank Gay below...
(MyDjangoProject)MyMacPro:MyDjangoProject rhenru$ which python
/Users/rhenru/Workspace/django/MyDjangoProject/bin/python
After I run python in virtualenv, importing MySQLdb:
>>> import MySQLdb
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "build/bdist.macosx-10.6-universal/egg/MySQLdb/__init__.py", line 19, in <module>
File "build/bdist.macosx-10.6-universal/egg/_mysql.py", line 7, in <module>
File "build/bdist.macosx-10.6-universal/egg/_mysql.py", line 6, in __bootstrap__
ImportError: dlopen(/Users/rhenru/.python-eggs/MySQL_python-1.2.3c1-py2.6-macosx-10.6-universal.egg-tmp/_mysql.so, 2): Symbol not found: _mysql_affected_rows
Referenced from: /Users/rhenru/.python-eggs/MySQL_python-1.2.3c1-py2.6-macosx-10.6-universal.egg-tmp/_mysql.so
Expected in: flat namespace
in /Users/rhenru/.python-eggs/MySQL_python-1.2.3c1-py2.6-macosx-10.6-universal.egg-tmp/_mysql.so
import sys and sys.path
>>> import sys
>>> print sys.path
['', '/Users/rhenru/Workspace/django/MyDjangoProject/lib/python2.6/site-packages/distribute-0.6.10-py2.6.egg', '/Users/rhenru/Workspace/django/MyDjangoProject/lib/python2.6/site-packages/pip-0.7.1-py2.6.egg', '/Users/rhenru/Workspace/django/MyDjangoProject/lib/python26.zip', '/Library/Python/2.6/site-packages/PyXML-0.8.4-py2.6-macosx-10.6-universal.egg', '/Library/Python/2.6/site-packages/pydot-1.0.2-py2.6.egg', '/Library/Python/2.6/site-packages/pyparsing-1.5.2-py2.6.egg', '/Library/Python/2.6/site-packages/vobject-0.8.1c-py2.6.egg', '/Library/Python/2.6/site-packages/pytz-2010h-py2.6.egg', '/Library/Python/2.6/site-packages/MySQL_python-1.2.3c1-py2.6-macosx-10.6-universal.egg', '/Library/Python/2.6/site-packages/distribute-0.6.12-py2.6.egg', '/Library/Python/2.6/site-packages/pip-0.7.1-py2.6.egg', '/Users/rhenru/Workspace/django/MyDjangoProject/lib/python2.6', '/Users/rhenru/Workspace/django/MyDjangoProject/lib/python2.6/plat-darwin', '/Users/rhenru/Workspace/django/MyDjangoProject/lib/python2.6/plat-mac', '/Users/rhenru/Workspace/django/MyDjangoProject/lib/python2.6/plat-mac/lib-scriptpackages', '/Users/rhenru/Workspace/django/MyDjangoProject/Extras/lib/python', '/Users/rhenru/Workspace/django/MyDjangoProject/lib/python2.6/lib-tk', '/Users/rhenru/Workspace/django/MyDjangoProject/lib/python2.6/lib-old', '/Users/rhenru/Workspace/django/MyDjangoProject/lib/python2.6/lib-dynload', '/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6', '/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/plat-darwin', '/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/lib-tk', '/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/plat-mac', '/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/plat-mac/lib-scriptpackages', '/Users/rhenru/Workspace/django/MyDjangoProject/lib/python2.6/site-packages', '/Library/Python/2.6/site-packages', '/Library/Python/2.6/site-packages/PIL', '/Library/Python/2.6/site-packages/setuptools-0.6c11-py2.6.egg-info', '/System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python', '/System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python/PyObjC', '/System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python/wx-2.8-mac-unicode']
How are you installing MySQL-Python? I just tested in a fresh virtualenv and pip install mysql-python seems to have done the trick.
UPDATE:
pip is sort of like a package manager for Python packages.
By default, pip installs to your current site-packages directory, which is on your $PYTHONPATH. This lets other libraries/applications (like Django) access it. pip also works well with virtualenv (it should; Ian Bicking wrote them both), which is a nifty library that lets you sandbox an application. This is nice because it means you can try out new things without polluting (or even needing write access to) the global site-packages directory.
It probably seems like yak-shaving right now, but I'd say it's worth the effort to get up to speed on pip and virtualenv (you may also want to look into virtualenvwrapper, but we'll skip that for now; it's just sugar for virtualenv). It will lead to a slightly more complicated deployment scenario than putting everything in the global site-packages, but for development it's really no harder, and there are lots of good guides to deploying using a virtualenv.
I'd recommend something like the following:
curl -0 http://python-distribute.org/distribute_setup.py
python distribute_setup.py
easy_install pip
pip install virtualenv
virtualenv --distribute MyDjangoProject --no-site-packages
cd MyDjangoProject
source bin/activate (this activates the sandbox that virtualenv created)
pip install django mysql-python
At this point, you should have a totally functional Django+MySQL install (if I missed any steps, just comment and I'll try to add it in). You can start your Django project like this: django-admin.py startproject MyDjangoProject. cd into your project's directory, edit your settings.py file to point to your MySQL database, and run the dev server to test it out like so: ./manage.py runserver (you may need to chmod u+x your manage.py file). Voila! You should be able to access your site on localhost:8000. When you're done working on the project, you can just use deactivate to exit the virtualenv sandbox.
Try not to hold all this against Django: a lot of it is just best practices stuff for working with Python libraries. You could get by with a lot less, but this way it's more reproducible and you're less likely to accidentally mess up one of this project's dependencies when working on a different project.
I had this problem and it turned out to be due to an errant configuration:
export VERSIONER_PYTHON_PREFER_32_BIT=yes
I can't recall what I had this enabled for (some package that required 32-bit), probably related to Google AppEngine. But Setting it to 'no' solved by issues.
Otherwise I just installed everything using homebrew and pip.

Categories