以下是如何重现我的问题:
创建一个新的virtualenv:
$ virtualenv testenv --python=/usr/bin/python3.6
Running virtualenv with interpreter /usr/bin/python3.6
Using base prefix '/usr'
New python executable in testenv/bin/python3.6
Also creating executable in testenv/bin/python
Installing setuptools, pip, wheel...done.
$ source testenv/bin/activate
(testenv) $ cd test
安装jieba并检查__version__
:
(testenv) test$ pip3 install jieba
Collecting jieba
Installing collected packages: jieba
Successfully installed jieba-0.39
(testenv) test$ python
Python 3.6.5 (default, Mar 29 2018, 03:28:50)
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import jieba
>>> jieba.__version__
'0.39'
>>> Quit (core dumped)
好的,版本0.39。
安装jieba3k:
(testenv) test$ pip3 install jieba3k
Collecting jieba3k
Installing collected packages: jieba3k
Successfully installed jieba3k-0.35.1
重新检查jieba __version__
:
(testenv) test$ python
Python 3.6.5 (default, Mar 29 2018, 03:28:50)
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import jieba
>>> jieba.__version__
'0.34'
>>> Quit (core dumped)
新版本为0.34。
为什么会这样?我怎么能避免这个?
答案 0 :(得分:0)
jieba
和jieba3k
不是两个不同的包,它们是同一个包的两个不同版本,jieba
更新。安装jieba3k
时,它会使用旧版本覆盖包jieba
。
简而言之:忘记jieba3k
,只使用jieba
。