Pyramid Framework附帶了一個使用sqlite的sql鍊金術示例教程。問題是,我想使用MySQL的,所以我改變這種在金字塔框架中使用Mysql和SqlAlchemy
sqlalchemy.url = sqlite:///%(here)s/tutorial.db
進入這個
sqlalchemy.url = mysql://root:[email protected]/alchemy
當我嘗試運行
../bin/pserve development.ini --reload
它給了我下面的錯誤
File "build/bdist.linux-i686/egg/sqlalchemy/connectors/mysqldb.py", line 52, in dbapi
ImportError: No module named MySQLdb
我明白我應包括我在setup.py應用程序的依賴條件,但我不知道現在一些幫助,請我setup.py看起來像這樣
import os
import sys
from setuptools import setup, find_packages
here = os.path.abspath(os.path.dirname(__file__))
README = open(os.path.join(here, 'README.txt')).read()
CHANGES = open(os.path.join(here, 'CHANGES.txt')).read()
requires = [
'pyramid',
'SQLAlchemy',
'transaction',
'pyramid_tm',
'pyramid_debugtoolbar',
'zope.sqlalchemy',
]
if sys.version_info[:3] < (2,5,0):
requires.append('pysqlite')
setup(name='tutorial',
version='0.0',
description='tutorial',
long_description=README + '\n\n' + CHANGES,
classifiers=[
"Programming Language :: Python",
"Framework :: Pylons",
"Topic :: Internet :: WWW/HTTP",
"Topic :: Internet :: WWW/HTTP :: WSGI :: Application",
],
author='',
author_email='',
url='',
keywords='web wsgi bfg pylons pyramid',
packages=find_packages(),
include_package_data=True,
zip_safe=False,
test_suite='tutorial',
install_requires = requires,
entry_points = """\
[paste.app_factory]
main = tutorial:main
[console_scripts]
populate_tutorial = tutorial.scripts.populate:main
""",
)
我試過了,它給了我以下錯誤對於教程== 安裝的/ home /丹尼斯/桌面/ pyramidtut /教程 處理依賴性0.0 搜索MySQLdb的 閱讀http://pypi.python.org/simple/MySQLdb/ 找不到「索引頁MySQLdb的」(也許拼錯?)所有包的 掃描索引(這可能需要一段時間) 閱讀http://pypi.python.org/simple/ 發現MySQLdb的 最佳匹配局部無包或下載鏈接:無 – Madawar 2012-01-07 22:12:18
當我在Python shell中運行導入MySQLdb時,它不會給出錯誤,所以肯定它的正確安裝 – Madawar 2012-01-07 22:15:25
金字塔應該有一套不同的軟件包到您的系統的python shell(它使用virtualenv沒有站點包),所以你有MySQLdb中在你的系統上停滯不前,而不是在金字塔virtualenv。 – DaedalusFall 2012-01-07 22:31:20