关于CentOS 7下sqlite3找不到的问题解决
本文主要给大家介绍的关于CentOS7下sqlite3找不到问题的解决方法,分享出来供大家参考学习,下面来一起看看详细的介绍:
Centos7下的nltk启动问题
CentOS7,Python3.6,ipython6.0.0
问题描述
ipython
启动ipython命令
importnltk
爆出以下的错误信息:
In[1]:importnltk --------------------------------------------------------------------------- ModuleNotFoundErrorTraceback(mostrecentcalllast)in () ---->1importnltk /opt/python36env/lib/python3.6/site-packages/nltk/__init__.pyin () 135fromnltk.translateimport* 136fromnltk.semimport* -->137fromnltk.stemimport* 138 139#Packageswhichcanbelazilyimported /opt/python36env/lib/python3.6/site-packages/nltk/stem/__init__.pyin () 27fromnltk.stem.isriimportISRIStemmer 28fromnltk.stem.porterimportPorterStemmer --->29fromnltk.stem.snowballimportSnowballStemmer 30fromnltk.stem.wordnetimportWordNetLemmatizer 31fromnltk.stem.rslpimportRSLPStemmer /opt/python36env/lib/python3.6/site-packages/nltk/stem/snowball.pyin () 24 25fromnltkimportcompat --->26fromnltk.corpusimportstopwords 27fromnltk.stemimportporter 28fromnltk.stem.utilimportsuffix_replace /opt/python36env/lib/python3.6/site-packages/nltk/corpus/__init__.pyin () 64fromnltk.tokenizeimportRegexpTokenizer 65fromnltk.corpus.utilimportLazyCorpusLoader --->66fromnltk.corpus.readerimport* 67 68abc=LazyCorpusLoader( /opt/python36env/lib/python3.6/site-packages/nltk/corpus/reader/__init__.pyin () 103fromnltk.corpus.reader.categorized_sentsimport* 104fromnltk.corpus.reader.comparative_sentsimport* -->105fromnltk.corpus.reader.panlex_liteimport* 106 107#Makesurethatnltk.corpus.reader.bracket_parsegivesthemodule,not /opt/python36env/lib/python3.6/site-packages/nltk/corpus/reader/panlex_lite.pyin () 13 14importos --->15importsqlite3 16 17fromnltk.corpus.reader.apiimportCorpusReader /usr/local/lib/python3.6/sqlite3/__init__.pyin () 21#3.Thisnoticemaynotberemovedoralteredfromanysourcedistribution. 22 --->23fromsqlite3.dbapi2import* /usr/local/lib/python3.6/sqlite3/dbapi2.pyin () 25importcollections.abc 26 --->27from_sqlite3import* 28 29paramstyle="qmark" ModuleNotFoundError:Nomodulenamed'_sqlite3'
从错误信息来分析,可以发现,就是sqlite3找不到而已。
问题分析与解决
那就尝试看看sqlite3是否已经安装:
yumsearchsqlite3
yumsearchsqlite3 Loadedplugins:fastestmirror Loadingmirrorspeedsfromcachedhostfile ===============================================================================N/Smatched:sqlite3================================================================================ libsqlite3x.x86_64:AC++WrapperfortheSQLite3embeddableSQLdatabaseengine libsqlite3x-devel.x86_64:Developmentfilesforlibsqlite3x preludedb-sqlite3.x86_64:PlugintousepreludewithaSQLite3database rubygem-sqlite3.x86_64:AllowsRubyscriptstointerfacewithaSQLite3database rubygem-sqlite3-doc.noarch:Documentationforrubygem-sqlite3 soci-sqlite3.x86_64:SQLite3back-endforsoci soci-sqlite3-devel.x86_64:SQLite3back-endforsoci uwsgi-plugin-sqlite3.x86_64:uWSGI-SQLite3plugin dspam-sqlite3.x86_64:SQLitev3.xstoragedriverforlibdspam golang-googlecode-sqlite-devel.i686:Trivialsqlite3bindingforGo golang-googlecode-sqlite-devel.x86_64:Trivialsqlite3bindingforGo libsq3.x86_64:AC++WrapperfortheSQLite3embeddableSQLdatabaseengine libsq3-devel.x86_64:Developmentfilesforlibsqlite3x opendbx-sqlite.x86_64:SQLite3backend-providessqlite3supportinopendbx python-sqlite3dbm.noarch:SQLite-backeddictionaryconformingtothedbminterface sqlite-devel.i686:Developmenttoolsforthesqlite3embeddableSQLdatabaseengine sqlite-devel.x86_64:Developmenttoolsforthesqlite3embeddableSQLdatabaseengine sqlite-tcl.x86_64:Tclmoduleforthesqlite3embeddableSQLdatabaseengine sqlite3-dbf.x86_64:ConverterofXBase/FoxProtablestoSQLite zabbix20-proxy-sqlite3.x86_64:ZabbixproxycompiledtouseSQLite zabbix22-dbfiles-sqlite3.noarch:Zabbixdatabaseschemasandpatches zabbix22-proxy-sqlite3.x86_64:ZabbixproxycompiledtouseSQLite
找到了sqlite3-devel,那就安装好了
yuminstallsqlite-devel
yuminstallsqlite-devel Loadedplugins:fastestmirror Loadingmirrorspeedsfromcachedhostfile ResolvingDependencies -->Runningtransactioncheck --->Packagesqlite-devel.x86_640:3.7.17-8.el7willbeinstalled -->FinishedDependencyResolution DependenciesResolved ===================================================================================================================================================================================== PackageArchVersionRepositorySize ===================================================================================================================================================================================== Installing: sqlite-develx86_643.7.17-8.el7base104k TransactionSummary ===================================================================================================================================================================================== Install1Package Totaldownloadsize:104k Installedsize:366k Isthisok[y/d/N]:y Downloadingpackages: sqlite-devel-3.7.17-8.el7.x86_64.rpm|104kB00:00:00 Runningtransactioncheck Runningtransactiontest Transactiontestsucceeded Runningtransaction Installing:sqlite-devel-3.7.17-8.el7.x86_641/1 Verifying:sqlite-devel-3.7.17-8.el7.x86_641/1 Installed: sqlite-devel.x86_640:3.7.17-8.el7 Complete!
问题没有解决
重新启动ipython
importnltk
但是问题依然存在,哪里出的问题呢?
问题最终解决
虽然安装了sqlite3的数据库,但是对于ipython的环境来说,确实无法找到sqlite3。
于是,我重新编译,并且安装了一下python3。
注意:这个是在sqlite3安装成功之后,在安装python的运行环境。
于是重新启动ipython,问题消逝,一切正常,本质上就是sqlite3的安装,以及sqlite3与python运行环境之间的匹配的问题。
总结
以上就是这篇文章的全部内容了,希望本文的内容对大家的学习或者工作能带来一定的帮助,如果有疑问大家可以留言交流,谢谢大家对毛票票的支持。