You are not logged in.

#1 2011-04-20 07:21:57

ntsp
Member
Registered: 2009-04-08
Posts: 2

SQLAlchemy fails to import in script, but works in shell

I'm trying to use SQLAlchemy in a python script, but it fails to import. A simple "import sqlalchemy" gives me this:

 Traceback (most recent call last):
  File "/home/ntsp/workspace/numtest/src/main.py", line 2, in <module>
    from numbers import *
  File "/home/ntsp/workspace/numtest/src/numbers.py", line 2, in <module>
    import sqlalchemy 
  File "/usr/lib/python3.2/site-packages/sqlalchemy/__init__.py", line 52, in <module>
    from sqlalchemy.types import (
  File "/usr/lib/python3.2/site-packages/sqlalchemy/types.py", line 25, in <module>
    from decimal import Decimal as _python_Decimal
  File "/usr/lib/python3.2/decimal.py", line 3762, in <module>
    _numbers.Number.register(Decimal)
AttributeError: 'module' object has no attribute 'Number'

This happens for both python3 and python2. In a python shell, I can import and use it just fine. I'm not sure what's going on.

Offline

#2 2011-04-21 00:25:43

Mr.Elendig
#archlinux@freenode channel op
From: The intertubes
Registered: 2004-11-07
Posts: 4,094

Re: SQLAlchemy fails to import in script, but works in shell

Maybe because your numbers.py masks the one in the stdlib?
Check out relative versus absolute imports etc.


Evil #archlinux@libera.chat channel op and general support dude.
. files on github, Screenshots, Random pics and the rest

Offline

#3 2011-04-21 01:16:06

ntsp
Member
Registered: 2009-04-08
Posts: 2

Re: SQLAlchemy fails to import in script, but works in shell

Oh wow, I have no idea how I missed that. I feel like an idiot now :\

Thanks for the help.

Offline

Board footer

Powered by FluxBB