我成功安装了nltk并在python 3.6.3中正常工作。我必须运行一个导入nltk和tensorflow的文件,因此,我必须激活tensorflow。
HP-250-G5-Notebook-PC:~$ python
Python 3.6.3 |Anaconda custom (64-bit)| (default, Oct 13 2017, 12:02:49)
[GCC 7.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import nltk
>>>
当我激活tensorflow似乎使用python 3.5.2。
(tensorflow)HP-250-G5-Notebook-PC:~/AIG2018/Chatbot$ python
Python 3.5.2 (default, Nov 23 2017, 16:37:01)
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import nltk
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
当我查找解决方案时,这是我尝试的但没有积极的结果。
(tensorflow) country_boy@Shikongo-Veijo-HP-250-G5-Notebook-PC:~$ pip install nltk
Traceback (most recent call last):
File "/home/country_boy/tensorflow/bin/pip", line 6, in <module>
from pkg_resources import load_entry_point
File "/home/country_boy/tensorflow/lib/python3.5/site-packages/pkg_resources/__init__.py", line 2927, in <module>
@_call_aside
File "/home/country_boy/tensorflow/lib/python3.5/site-packages/pkg_resources/__init__.py", line 2913, in _call_aside
f(*args, **kwargs)
File "/home/country_boy/tensorflow/lib/python3.5/site-packages/pkg_resources/__init__.py", line 2952, in _initialize_master_working_set
add_activation_listener(lambda dist: dist.activate())
File "/home/country_boy/tensorflow/lib/python3.5/site-packages/pkg_resources/__init__.py", line 956, in subscribe
callback(dist)
File "/home/country_boy/tensorflow/lib/python3.5/site-packages/pkg_resources/__init__.py", line 2952, in <lambda>
add_activation_listener(lambda dist: dist.activate())
File "/home/country_boy/tensorflow/lib/python3.5/site-packages/pkg_resources/__init__.py", line 2515, in activate
declare_namespace(pkg)
File "/home/country_boy/tensorflow/lib/python3.5/site-packages/pkg_resources/__init__.py", line 2097, in declare_namespace
_handle_ns(packageName, path_item)
File "/home/country_boy/tensorflow/lib/python3.5/site-packages/pkg_resources/__init__.py", line 2047, in _handle_ns
_rebuild_mod_path(path, packageName, module)
File "/home/country_boy/tensorflow/lib/python3.5/site-packages/pkg_resources/__init__.py", line 2066, in _rebuild_mod_path
orig_path.sort(key=position_in_sys_path)
AttributeError: '_NamespacePath' object has no attribute 'sort'
我认为这与pip有关。 问题是如何在python 3.5.2中安装nltk ???或者我如何让一切工作?