Centos6.6+Python3报错ImportError: No module named pysqlite2
程序员文章站
2022-03-03 16:17:00
...
问题:启动jupyter报错
命令行输入:jupyter notebook
报错:
Traceback (most recent call last): File "/usr/local/lib/python3.6/sitepackages/notebook/services/sessions/sessionmanager.py", line 10, in <module>
import sqlite3
File "/usr/local/lib/python3.6/Frameworks/Python.framework/Versions/3.6/lib/python3.6/sqlite3/__init__.py", line 23, in <module>
from sqlite3.dbapi2 import *
File "/usr/local/lib/python3.6/Frameworks/Python.framework/Versions/3.6/lib/python3.6/sqlite3/dbapi2.py", line 27, in <module>
from _sqlite3 import *
ImportError: dlopen(/usr/local/lib/python3.6//Frameworks/Python.framework/Versions/3.6/lib/python3.6/lib-dynload/_sqlite3.cpython-37m-darwin.so, 2): Symbol not found: _sqlite3_enable_load_extension
Referenced from: /usr/local/lib/python3.6//Frameworks/Python.framework/Versions/3.6/lib/python3.6/lib-dynload/_sqlite3.cpython-37m-darwin.so
Expected in: /usr/lib/libsqlite3.dylib
in /usr/local/lib/python3.6//Frameworks/Python.framework/Versions/3.6/lib/python3.6/lib-dynload/_sqlite3.cpython-37m-darwin.so
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/bin/jupyter-notebook", line 7, in <module>
from notebook.notebookapp import main
File "/usr/local/lib/python3.6/site-packages/notebook/notebookapp.py", line 86, in <module>
from .services.sessions.sessionmanager import SessionManager
File "/usr/local/lib/python3.6/site-packages/notebook/services/sessions/sessionmanager.py", line 13, in <module>
from pysqlite2 import dbapi2 as sqlite3
ModuleNotFoundError: No module named 'pysqlite2'
解决办法
试了好多方法,最终还是解决了,开心
1安装sqlite-devel
yum install sqlite-devel -y
重新编译python
tar -zxvf Python-3.6.6.tgz
cd Python-3.6.6
./configure --prefix=/usr/local/python3.6.0
./configure --with-ssl
make && make install
重启jupyter notebook
提示:
Running as root is not recommended. Use --allow-root to bypass
然后执行:
[......]$ jupyter notebook --generate-config --allow-root
Overwrite /root/.jupyter/jupyter_notebook_config.py with default config? [y/N]y
Writing default config to:/root/.jupyter/jupyter_notebook_config.py
打开配置文件
gedit /root/.jupyter/jupyter_notebook_config.py
找到下面这一行#c.NotebookApp.allow_root = False
去掉注释,将False改成Truec.NotebookApp.allow_root = True
保存后重新启动jupyter
参考:1、Python3报错ImportError: No module named pysqlite2
2、Running as root is not recommended. Use --allow-root to bypass
推荐阅读
-
下载python中Crypto库报错:ModuleNotFoundError: No module named ‘Crypto’的解决
-
from dns.resolver import Resolver ImportError: No module named dns.resolver
-
解决方法:在Python中使用Win32api报错的问题,No module named win32api
-
pycharm运行出现ImportError:No module named的解决方法
-
Django重装mysql后启动报错:No module named ‘MySQLdb’的解决方法
-
Centos7 执行firewall-cmd –permanent –add-service=mysql报错“ModuleNotFoundError: No module named 'gi'”
-
Linux—运行yum报错:No module named yum
-
PyCharm导入pymysql包运行报错问题解决:No module named 'PyMySQL'
-
flask-关于ImportError: No module named 'flask.ext'
-
解决pycharm终端/cmd运行python脚本报错“ImportError/ModuleNotFoundError:No Module named ...”