jupyter怎么安装jieba_AI工具:Anaconda中Jupyter不能import已安装module问题解决

jupyter模式下写代码时,通过pip install package命令行安装package完成之后,无法在jupyter模式下import ,这是个通用的问题,我这里遇到的是import jieba,可能import 别的package也会出现,记录下,也花了点时间排查。。。

环境

windows10

anaconda3

jieba

python3

问题

python3版本,已经安装好了jieba模块,并且已经本地写个.py的测试jieba分词的python文件可以运行

但是就是在jupyter notebook中无法import。类似其他module也会有类似情况

如下

---------------------------------------------------------------------------

ModuleNotFoundError Traceback (most recent call last)

in

5 import pandas as pd

6 import numpy as np

----> 7 import jieba

8 import codecs

9 import re

ModuleNotFoundError: No module named 'jieba'

解决

乍一看就是jieba模块不存在,但是实际上python环境已经安装过了,如下检查

C:\Users\明柯>pip install jieba

Requirement already satisfied: jieba in e:\study\python3\lib\site-packages (0.39)

说明跟有无安装jieba这个东西无关,而是jupyter notebook认为没安装,没找到这个。

检查当前系统下的module脚本安装路径(也可以理解为编译路径)

C:\Users\明柯>python

Python 3.7.0 (v3.7.0:1bf9cc5093, Jun 27 2018, 04:59:51) [MSC v.1914 64 bit (AMD64)] on win32

Type "help", "copyright", "credits" or "license" for more information.

>>> import sys

>>> sys.path

['', 'E:\\study\\Python3\\python37.zip', 'E:\\study\\Python3\\DLLs', 'E:\\study\\Python3\\lib', 'E:\\study\\Python3', 'E:\\study\\Python3\\lib\\site-packages']

>>>

检查jupyter notebook运行环境下的脚本安装路径(编译路径),我的notebook是在anoconda3里的,如下

如下是在jupyter notebook浏览器里打开的ipython3文件里操作

In [1]: import sys

In [2]: sys.path

Out[2]: ['D:\\GitTest\\badou\\QAboard\\work\\class1\\45',

'E:\\study\\anacoda3\\python37.zip',

'E:\\study\\anacoda3\\DLLs',

'E:\\study\\anacoda3\\lib',

'E:\\study\\anacoda3',

'',

'E:\\study\\anacoda3\\lib\\site-packages',

'E:\\study\\anacoda3\\lib\\site-packages\\win32',

'E:\\study\\anacoda3\\lib\\site-packages\\win32\\lib',

'E:\\study\\anacoda3\\lib\\site-packages\\Pythonwin',

'E:\\study\\anacoda3\\lib\\site-packages\\IPython\\extensions',

'C:\\Users\\明柯\\.ipython']

如上可知,系统的路径与anaconda3的jupyter notebook理解的路径不一样,所以有这个问题。因为anaconda3自己会安装需要的module,且不会和系统混合公用,所以他名下的模块安装路径(编译路径)肯定和系统的python模块路径不一样。

解决:进入到E:\study\anacoda3这个路径下有个Scripts目录,在这里面文件路径栏里直接输入cmd(或者cmd 然后cd到E:\study\anacoda3\Scripts路径下),进行安装jieba

注意,若需要指定版本则pip install jieba=0.39这样

E:\study\anacoda3\Scripts>pip install jieba

Collecting jieba

Downloading jieba-0.42.1.tar.gz (19.2 MB)

|████████████████████████████████| 19.2 MB 939 kB/s

Building wheels for collected packages: jieba

Building wheel for jieba (setup.py) ... done

Created wheel for jieba: filename=jieba-0.42.1-py3-none-any.whl size=19314481 sha256=ac593ad59de55018cc6750101fe6cab7b9e1a3695fbb26044dd3c3ae0a10a0ca

Stored in directory: c:\users\明柯\appdata\local\pip\cache\wheels\24\aa\17\5bc7c72e9a37990a9620cc3aad0acad1564dcff6dbc2359de3

Successfully built jieba

Installing collected packages: jieba

Successfully installed jieba-0.42.1

E:\study\anacoda3\Scripts>

验证

安装完毕后,再次去jupyter notebook里试下import jieba

In [3]: import jieba

In [4]: # 全模式

seg_list = jieba.cut("南京市长江大桥",cut_all=True)

print(",".join(seg_list))

Building prefix dict from the default dictionary ...

Dumping model to file cache C:\Users\明柯\AppData\Local\Temp\jieba.cache

Loading model cost 1.001 seconds.

Prefix dict has been built successfully.

南京,南京市,京市,市长,长江,长江大桥,大桥

如有更简便的解决方案欢迎讨论

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/442067.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

Sql Server数据库设置一个账户只能看到一个数据库

1 新建登录名,注意不要设置用户映射,服务器角色只选择public(默认必选,无法去掉,可以添加其他服务器角色,但是不要添加查看所有数据库的权限,接下来会去掉public的查看所有数据库权限&#xff0…

boot lib分离 spring_spring boot + gradle打包bootJar分离lib

以前项目打包一直是用的maven,最近新开一个项目,使用的是spring boot 2.11 gradle 4.10.3,在打包的时候分离lib折腾了好几天,网上找了很多方法都不成功,老是卡在configurations.compile这里,总是获取不到正…

【POJ - 3494】Largest Submatrix of All 1’s(加一点思维后化成 单调栈)

题干: Given a m-by-n (0,1)-matrix, of all its submatrices of all 1’s which is the largest? By largest we mean that the submatrix has the most elements. Input The input contains multiple test cases. Each test case begins with m and n (1 ≤ m…

如何在修改计算机设置时,不再弹出提示框?

1 打开控制面板,找到安全与维护; 2 进入安全与维护,在安全中找到“用户账户控制UAC”,点击打开“更改设置” 3 进行设置,“从不通知”设置之后,针对计算机的所有更改将不再提示

doe五步法_DOE方法介绍

DOE, Design of Experiment。就是试验设计。想知道对于某个过程的产生影响的诸多因素中对输出结果影响最关键的因素有哪些,就可以用DOE方法来设计一系列试验,获知关键影响因素。通常的确定对输出变量最关键影响因子的试验做法有三种。1. 经验猜测法。首先…

【POJ - 1789】【ZOJ - 2158】【SCU - 1832】Truck History (最小生成树)

题干: Description Advanced Cargo Movement, Ltd. uses trucks of different types. Some trucks are used for vegetable delivery, other for furniture, or for bricks. The company has its own code describing each type of a truck. The code is simply a…

matlab两张图片合成一张_11. 图像合成与图像融合

本文同步发表在我的微信公众号“计算摄影学”,欢迎扫码关注【转载请注明来源和作者】我们终于进入了新的篇章。这一次我来给大家介绍一下图像合成与融合。我们经常看到一些很奇妙的PS技术,例如下面这张,它把1928年的一位叫做Frankie Yale的黑…

C#学习,Web界面打开winform程序

1 Web打开winform程序&#xff0c;需要使用的标签为a标签 <a href"SelfName://">连接提示</a> //SelfName 是自己的自定义协议2 Winform程序一般不需要做任何操作&#xff0c;如果需要参数传递的情况下&#xff0c;可以将Winform的Program.cs程序修…

【POJ - 2349】【UVA - 10369】 Arctic Network(最小生成树求权值第k大的边)(内附两种算法)

题干&#xff1a; The Department of National Defence (DND) wishes to connect several northern outposts by a wireless network. Two different communication technologies are to be used in establishing the network: every outpost will have a radio transceiver a…

asp.net MVC结合Blazor开发学习

1建立MVC项目&#xff08;.net 6&#xff09;; 2 在项目启动文件Program.cs中添加Blazor框架&#xff1b; var builder WebApplication.CreateBuilder(args);// Add services to the container. builder.Services.AddControllersWithViews(); builder.Services.AddServerSid…

澄海口袋机器人_汕头市澄海区在2019年汕头市中小学智能机器人竞赛上取得优异成绩...

4月14日&#xff0c;2019年汕头市中小学智能机器人竞赛在汕头市蓬鸥中学举行。本次活动由汕头市教育局和汕头市科协联合主办&#xff0c;全市93所学校的249个队伍503名选手报名参赛&#xff0c;大赛设“高铁时代”机器人现场拼装赛、丛林任务挑战赛、超级轨迹赛、综合技能比赛、…

【POJ - 1703】Find them, Catch them(带权并查集之--种类并查集 权为与父节点关系)

题干&#xff1a; Find them, Catch them Time Limit: 1000MS Memory Limit: 10000KTotal Submissions: 36176 Accepted: 11090 Description The police office in Tadu City decides to say ends to the chaos, as launch actions to root up the TWO gangs in the city, Ga…

h5前端如何实现F11全屏功能

网站全部实现小demo&#xff1a;兼容谷歌和Edge {Layout null; }<!DOCTYPE html><html> <head><meta name"viewport" content"widthdevice-width" /><title>Index</title><script src"~/Content/jquery/jque…

于小c三国语言_云顶之弈:三国成最强打工羁绊 校长教学顺滑转九五

虎牙校长是九五阵容的专业户&#xff0c;虽然版本在不断地更新&#xff0c;云顶的整体走向也在不断地发生变化&#xff0c;但九五至尊的强度一直都是TOP0级别&#xff0c;一旦成型第四保底&#xff0c;吃鸡都变得轻而易举。而整套九五的运营关键在于如何连胜、保证自身血量健康…

【HDU - 3172】Virtual Friends(带权并查集--权为集合元素个数)

题干&#xff1a; These days, you can do all sorts of things online. For example, you can use various websites to make virtual friends. For some people, growing their social network (their friends, their friends friends, their friends friends friends, and …

java null转换jason_常见java问题及解决办法汇总(干货可收藏)

Java Exception&#xff1a;1、Error2、Runtime Exception 运行时异常3、Exception4、throw 用户自定义异常异常类分两大类型&#xff1a;Error类代表了编译和系统的错误&#xff0c;不允许捕获&#xff1b;Exception类代表了标准Java库方法所激发的异常。Exception类还包含运行…

asp.net 网站开发,word导出

曾经有一个word导出案例&#xff1a; web保存word资源 后来发现可以使用MVC的File方法保存成相应的文件&#xff0c;特别做个记录。 1 前端 //网页 <form method"post" action"/Home/WordExport" id"wordTmp"><input type"text&…

【HDU - 3038】How Many Answers Are Wrong (带权并查集--权为区间和)

题干&#xff1a;&#xff08;&#xff09; TT and FF are ... friends. Uh... very very good friends -________-b FF is a bad boy, he is always wooing TT to play the following game with him. This is a very humdrum game. To begin with, TT should write down a s…

drop sqlite 多个表_SQLite简介与安装

SQLite简介&#xff1a;SQLite是一款轻型的数据库&#xff0c;是遵守ACID的关系型数据库管理系统&#xff0c;它包含在一个相对小的C库中&#xff0c;实现了自给自足的、无服务器的、零配置的、事务性的 SQL 数据库引擎。就像其他数据库&#xff0c;SQLite 引擎不是一个独立的进…

【CF566#D】 Restructuring Company (并查集---合并区间操作)

题干&#xff1a; Even the most successful company can go through a crisis period when you have to make a hard decision — to restructure, discard and merge departments, fire employees and do other unpleasant stuff. Lets consider the following model of a c…