File "C:\Users\Administrator\anaconda3\lib\site-packages\streamlit\runtime\scriptrunner\script_runner.py", line 565, in _run_script exec(code, module.__dict__) File "D:\Users\Downloads\12-可视化\app.py", line 29, in <module> con = get_con() File "C:\Users\Administrator\anaconda3\lib\site-packages\streamlit\runtime\caching\cache_utils.py", line 194, in wrapper return cached_func(*args, **kwargs) File "C:\Users\Administrator\anaconda3\lib\site-packages\streamlit\runtime\caching\cache_utils.py", line 223, in __call__ return self._get_or_create_cached_value(args, kwargs) File "C:\Users\Administrator\anaconda3\lib\site-packages\streamlit\runtime\caching\cache_utils.py", line 248, in _get_or_create_cached_value return self._handle_cache_miss(cache, value_key, func_args, func_kwargs) File "C:\Users\Administrator\anaconda3\lib\site-packages\streamlit\runtime\caching\cache_utils.py", line 302, in _handle_cache_miss computed_value = self._info.func(*func_args, **func_kwargs) File "D:\Users\Downloads\12-可视化\app.py", line 8, in get_con return create_engine('postgresql+psycopg2://postgres:12344321@localhost:5432/traffic').connect() File "<string>", line 2, in create_engine File "C:\Users\Administrator\anaconda3\lib\site-packages\sqlalchemy\util\deprecations.py", line 309, in warned return fn(*args, **kwargs) File "C:\Users\Administrator\anaconda3\lib\site-packages\sqlalchemy\engine\create.py", line 560, in create_engine dbapi = dialect_cls.dbapi(**dbapi_args) File "C:\Users\Administrator\anaconda3\lib\site-packages\sqlalchemy\dialects\postgresql\psycopg2.py", line 782, in dbapi import psycopg2
时间: 2023-08-27 19:19:07 浏览: 242
python 3.74 运行import numpy as np 报错lib\site-packages\numpy\__init__.py
这是一个错误信息,它提示在运行代码时出现了错误。看起来是在连接 PostgreSQL 数据库时出现了问题。可能的原因包括:
1. 数据库连接信息配置错误,比如用户名、密码、主机地址等错误;
2. 数据库服务没有启动或者端口号不正确;
3. psycopg2 库没有正确安装或者版本不兼容。
建议你检查一下代码中连接数据库的相关配置,确保它们正确无误。如果仍然无法解决问题,可以尝试重新安装 psycopg2 库或者使用其他的数据库连接库。
阅读全文