2009-06-16 64 views
1

我想在OS X 10.5的virtualenv下使用SQLAlchemy,但似乎無法讓它加載任何。問題與SQLAlchemy和VirtualEnv

這裏是我做了什麼

mkvirtualenv --no-site-packages test 
easy_install sqlalchemy 

我嘗試解釋進口SQLAlchemy的,一切工作正常,但如果我試圖從Python腳本導入SQLAlchemy的,我得到以下錯誤:

下面是IBM

from sqlalchemy.ext.declarative import declarative_base 
from sqlalchemy import Table, Column, Integer, String, MetaData, ForeignKey 

Base = declarative_base() 
class Filesystem(Base): 
    __tablename__ = 'filesystem' 

    path = Column(String, primary_key=True) 
    name = Column(String) 

    def __init__(self, path,name): 
     self.path = path 
     self.name = name 

    def __repr__(self): 
     return "<Metadata('%s','%s')>" % (self.path,self.name) 

我嘗試運行「蟒蛇test.py」教程腳本,這就是結果:

$ python test.py 
Traceback (most recent call last): 
    File "test.py", line 4, in <module> 
    from sqlalchemy import Table, Column, Integer, String, MetaData, ForeignKey 
    File "/Users/grant/Development/Aircraft/sqlalchemy.py", line 3, in <module> 
    from sqlalchemy.ext.declarative import declarative_base 
ImportError: No module named ext.declarative 

下面是在我的sys.path

>>> import sys 
>>> print '\n'.join(sys.path) 

/Users/grant/Development/Python/test/lib/python2.6/site-packages/setuptools-0.6c9-py2.6.egg 
/Users/grant/Development/Python/test/lib/python2.6/site-packages/SQLAlchemy-0.5.4p2-py2.6.egg 
/Users/grant/Development/Python/test/lib/python26.zip 
/Users/grant/Development/Python/test/lib/python2.6 
/Users/grant/Development/Python/test/lib/python2.6/plat-darwin 
/Users/grant/Development/Python/test/lib/python2.6/plat-mac 
/Users/grant/Development/Python/test/lib/python2.6/plat-mac/lib-scriptpackages 
/Users/grant/Development/Python/test/lib/python2.6/lib-tk 
/Users/grant/Development/Python/test/lib/python2.6/lib-old 
/Users/grant/Development/Python/test/lib/python2.6/lib-dynload 
/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6 
/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/plat-darwin 
/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/lib-tk 
/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/plat-mac 
/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/plat-mac/lib-scriptpackages 
/Users/grant/Development/Python/test/lib/python2.6/site-packages 

上發生了什麼事的任何想法?

回答

8

我解決了我自己的問題......我在另一個腳本中命名爲sqlalchemy.py,在我工作的同一個文件夾中,這是一切都在磨蹭。

+2

大聲笑,我有一個不同的庫相同的問題。 – 2010-11-22 23:32:11