我是sqlalchemy的新手并尝试在mysql中创建表。处理虚拟环境并在命令下执行。 pip3安装sqlalchemy pip3 install sqlalchemy-migrate
Python版本-3.6.4 但是当我尝试在终端上执行命令“python models.py”时会弹出错误
文件“models.py”,第1行,in 来自sqlalchemy import表,Column,Integer,MetaData,ForeignKey,DateTime,Float,BigInteger,String,func ModuleNotFoundError:没有名为'sqlalchemy'的模块
from sqlalchemy import Table, Column, Integer, MetaData, ForeignKey, DateTime, Float, BigInteger, String, func
import helper.connection_util as connection_util
metadata = MetaData()
# employee TABLE
employee = Table('employee', metadata,
Column('employee_id', Integer, primary_key=True),
Column('employee_name', String(100)),
Column('employee_designation', String(100)),
metadata.create_all(connection_util.get_connection())
答案 0 :(得分:0)
听起来像sqlalchemy没有安装。您可以尝试使用sudo pip3 install sqlalchemy
。
您可以通过在交互模式下运行python并使用以下命令来确认安装:
$ python3
>>> import sqlalchemy
>>> sqlalchemy.__version__
这应该为您提供sqlalchemy的版本。