自然语言环境安装部署

Microsoft Windows [版本 10.0.22631.5335]
(c) Microsoft Corporation。保留所有权利。

C:\Users\flyycheng>d:

D:\>cd python

D:\python>ls -al
'ls' 不是内部或外部命令,也不是可运行的程序
或批处理文件。

D:\python>dir
 驱动器 D 中的卷是 DATA
 卷的序列号是 D88D-56AF

 D:\python 的目录

2025/07/14  16:07    <DIR>          .
2025/07/14  15:58    <DIR>          DLLs
2025/07/14  15:58    <DIR>          Doc
2025/07/14  15:58    <DIR>          include
2025/07/14  16:25    <DIR>          Lib
2025/07/14  15:58    <DIR>          libs
2021/05/03  11:54            32,628 LICENSE.txt
2021/05/03  11:55           955,561 NEWS.txt
2024/08/19  03:47    <DIR>          nltk
2025/07/14  16:05         2,904,691 nltk-3.9.1.tar.gz
2021/05/03  11:54           101,552 python.exe
2021/05/03  11:54           438,272 python.pdb
2021/05/03  11:54            59,568 python3.dll
2021/05/03  11:54         4,211,376 python38.dll
2021/05/03  11:54        11,939,840 python38.pdb
2021/05/03  11:54         8,145,408 python38_d.dll
2021/05/03  11:54         8,302,592 python38_d.pdb
2021/05/03  11:54            70,144 python3_d.dll
2021/05/03  11:54           100,016 pythonw.exe
2021/05/03  11:54           438,272 pythonw.pdb
2021/05/03  11:54           134,656 pythonw_d.exe
2021/05/03  11:54           569,344 pythonw_d.pdb
2021/05/03  11:54           136,704 python_d.exe
2021/05/03  11:54           569,344 python_d.pdb
2025/07/14  15:59    <DIR>          Scripts
2025/07/14  15:58    <DIR>          tcl
2025/07/14  15:58    <DIR>          Tools
2021/05/03  11:54            96,120 vcruntime140.dll
2021/05/03  11:54            36,728 vcruntime140_1.dll
              19 个文件     39,242,816 字节
              10 个目录 178,926,084,096 可用字节

D:\python>cd Scripts

D:\python\Scripts>dir
 驱动器 D 中的卷是 DATA
 卷的序列号是 D88D-56AF

 D:\python\Scripts 的目录

2025/07/14  15:59    <DIR>          .
2025/07/14  16:07    <DIR>          ..
2025/07/14  15:59           106,331 pip.exe
2025/07/14  15:59           106,331 pip3.8.exe
2025/07/14  15:59           106,331 pip3.exe
               3 个文件        318,993 字节
               2 个目录 178,926,084,096 可用字节

D:\python\Scripts>pip install nltk
Collecting nltk
  Downloading nltk-3.9.1-py3-none-any.whl (1.5 MB)
     |████████████████████████████████| 1.5 MB 726 kB/s
Collecting regex>=2021.8.3
  Downloading regex-2024.11.6-cp38-cp38-win_amd64.whl (274 kB)
     |████████████████████████████████| 274 kB 3.3 MB/s
Collecting joblib
  Downloading joblib-1.4.2-py3-none-any.whl (301 kB)
     |████████████████████████████████| 301 kB 6.4 MB/s
Collecting tqdm
  Downloading tqdm-4.67.1-py3-none-any.whl (78 kB)
     |████████████████████████████████| 78 kB 1.5 MB/s
Collecting click
  Downloading click-8.1.8-py3-none-any.whl (98 kB)
     |████████████████████████████████| 98 kB 3.8 MB/s
Collecting colorama
  Downloading colorama-0.4.6-py2.py3-none-any.whl (25 kB)
Installing collected packages: colorama, tqdm, regex, joblib, click, nltk
Successfully installed click-8.1.8 colorama-0.4.6 joblib-1.4.2 nltk-3.9.1 regex-2024.11.6 tqdm-4.67.1
WARNING: You are using pip version 21.1.1; however, version 25.0.1 is available.
You should consider upgrading via the 'd:\python\python.exe -m pip install --upgrade pip' command.

D:\python\Scripts>pip  -m pip install --upgrade pip

Usage:
  pip <command> [options]

no such option: -m

D:\python\Scripts>python  -m pip install --upgrade pip
Requirement already satisfied: pip in d:\python\lib\site-packages (21.1.1)
Collecting pip
  Downloading pip-25.0.1-py3-none-any.whl (1.8 MB)
     |████████████████████████████████| 1.8 MB 731 kB/s
Installing collected packages: pip
  Attempting uninstall: pip
    Found existing installation: pip 21.1.1
    Uninstalling pip-21.1.1:
      Successfully uninstalled pip-21.1.1
Successfully installed pip-25.0.1

D:\python\Scripts>pip install nltk
Requirement already satisfied: nltk in d:\python\lib\site-packages (3.9.1)
Requirement already satisfied: click in d:\python\lib\site-packages (from nltk) (8.1.8)
Requirement already satisfied: joblib in d:\python\lib\site-packages (from nltk) (1.4.2)
Requirement already satisfied: regex>=2021.8.3 in d:\python\lib\site-packages (from nltk) (2024.11.6)
Requirement already satisfied: tqdm in d:\python\lib\site-packages (from nltk) (4.67.1)
Requirement already satisfied: colorama in d:\python\lib\site-packages (from click->nltk) (0.4.6)

D:\python\Scripts>python
Python 3.8.10 (tags/v3.8.10:3d8993a, May  3 2021, 11:48:03) [MSC v.1928 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>>
>>>
>>> import nltk
>>> nltk.down('punkt')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: module 'nltk' has no attribute 'down'
>>>
>>>
>>> nltk.download('punkt')
[nltk_data] Downloading package punkt to
[nltk_data]     C:\Users\flyycheng\AppData\Roaming\nltk_data...
[nltk_data]   Unzipping tokenizers\punkt.zip.
True
>>>
>>>
>>>
>>> import nltk
>>>
>>> text="hello world!i am is fly!!"
>>> from nltk.tokenize import sent_tokenize
>>> sent_tokenize(text)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "D:\python\lib\site-packages\nltk\tokenize\__init__.py", line 119, in sent_tokenize
    tokenizer = _get_punkt_tokenizer(language)
  File "D:\python\lib\site-packages\nltk\tokenize\__init__.py", line 105, in _get_punkt_tokenizer
    return PunktTokenizer(language)
  File "D:\python\lib\site-packages\nltk\tokenize\punkt.py", line 1744, in __init__
    self.load_lang(lang)
  File "D:\python\lib\site-packages\nltk\tokenize\punkt.py", line 1749, in load_lang
    lang_dir = find(f"tokenizers/punkt_tab/{lang}/")
  File "D:\python\lib\site-packages\nltk\data.py", line 579, in find
    raise LookupError(resource_not_found)
LookupError:
**********************************************************************
  Resource punkt_tab not found.
  Please use the NLTK Downloader to obtain the resource:

  >>> import nltk
  >>> nltk.download('punkt_tab')

  For more information see: https://www.nltk.org/data.html

  Attempted to load tokenizers/punkt_tab/english/

  Searched in:
    - 'C:\\Users\\flyycheng/nltk_data'
    - 'D:\\python\\nltk_data'
    - 'D:\\python\\share\\nltk_data'
    - 'D:\\python\\lib\\nltk_data'
    - 'C:\\Users\\flyycheng\\AppData\\Roaming\\nltk_data'
    - 'C:\\nltk_data'
    - 'D:\\nltk_data'
    - 'E:\\nltk_data'
**********************************************************************

>>> import nltk
>>> nltk.download('punkt_tab')
[nltk_data] Downloading package punkt_tab to
[nltk_data]     C:\Users\flyycheng\AppData\Roaming\nltk_data...
[nltk_data]   Unzipping tokenizers\punkt_tab.zip.
True
>>> sent_tokenize(text)
['hello world!i am is fly!', '!']
>>> text = "Hello world! I am learning NLP. It is fun and useful!"
>>> sentences = sent_tokenize(text)
>>> print(sentences)
['Hello world!', 'I am learning NLP.', 'It is fun and useful!']
>>>
 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值