Проблемы настройки NLTK в среде Python - PullRequest
0 голосов
/ 30 мая 2019

Я новичок в программировании и пытаюсь загрузить NLTK для работы в чат-боте с Python.На данный момент я использую Python 2.7.Согласно документации для NLTK, «NLTK требует Python версий 2.7, 3.5, 3.6 или 3.7».

Я скачал Homebrew и выполнил команды, предложенные в документации, но получил сообщения об ошибках.

Leonas-MacBook-Air:~ leonaadriennestephanieponce$ sudo pip install -U nltk
Password:
Sorry, try again.
Password:
DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 won't be maintained after that date. A future version of pip will drop support for Python 2.7.
WARNING: The directory '/Users/leonaadriennestephanieponce/Library/Caches/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
WARNING: The directory '/Users/leonaadriennestephanieponce/Library/Caches/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Collecting nltk
  Downloading https://files.pythonhosted.org/packages/73/56/90178929712ce427ebad179f8dc46c8deef4e89d4c853092bee1efd57d05/nltk-3.4.1.zip (3.1MB)
     |████████████████████████████████| 3.1MB 548kB/s 
    ERROR: Complete output from command python setup.py egg_info:
    ERROR: error in nltk setup command: 'install_requires' must be a string or list of strings containing valid project/version requirement specifiers; Expected version spec in singledispatch; python_version < "3.4" at ; python_version < "3.4"
    ----------------------------------------
ERROR: Command "python setup.py egg_info" failed with error code 1 in /private/tmp/pip-install-OTcEsN/nltk/
Leonas-MacBook-Air:~ leonaadriennestephanieponce$ sudo easy_install pip
Password:
Sorry, try again.
Password:
Sorry, try again.
Password:
Searching for pip
Best match: pip 19.1.1
Processing pip-19.1.1-py2.7.egg
pip 19.1.1 is already the active version in easy-install.pth
Installing pip script to /usr/local/bin
Installing pip2.7 script to /usr/local/bin
Installing pip2 script to /usr/local/bin

Using /Library/Python/2.7/site-packages/pip-19.1.1-py2.7.egg
Processing dependencies for pip
Finished processing dependencies for pip
Leonas-MacBook-Air:~ leonaadriennestephanieponce$ sudo pip install -U nltk
DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 won't be maintained after that date. A future version of pip will drop support for Python 2.7.
WARNING: The directory '/Users/leonaadriennestephanieponce/Library/Caches/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
WARNING: The directory '/Users/leonaadriennestephanieponce/Library/Caches/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Collecting nltk
  Downloading https://files.pythonhosted.org/packages/73/56/90178929712ce427ebad179f8dc46c8deef4e89d4c853092bee1efd57d05/nltk-3.4.1.zip (3.1MB)
     |████████████████████████████████| 3.1MB 465kB/s 
    ERROR: Complete output from command python setup.py egg_info:
    ERROR: error in nltk setup command: 'install_requires' must be a string or list of strings containing valid project/version requirement specifiers; Expected version spec in singledispatch; python_version < "3.4" at ; python_version < "3.4"
    ----------------------------------------
ERROR: Command "python setup.py egg_info" failed with error code 1 in /private/tmp/pip-install-vY99RW/nltk/
Leonas-MacBook-Air:~ leonaadriennestephanieponce$ 

Согласно документации, доступной по адресу: https://www.nltk.org/install.html

Я попытался выполнить команду "sudo pip install -U nltk", которая вернула ошибки:

ERROR: Complete output from command python setup.py egg_info:
ERROR: error in nltk setup command: 'install_requires' must be a string or list of strings containing valid project/version requirement specifiers; Expected version spec in singledispatch; python_version < "3.4" at ; python_version < "3.4"
    ----------------------------------------
ERROR: Command "python setup.py egg_info" failed with error code 1 in /private/tmp/pip-install-OTcEsN/nltk/

Я также безуспешно попробовал предложение в нижней части страницы документации, а именно: «Для более старых версий Python может потребоваться установить setuptools (см. http://pypi.python.org/pypi/setuptools) и установить pip (sudo easy_install pip)».В результате возникли следующие ошибки:

ERROR: Complete output from command python setup.py egg_info:
ERROR: error in nltk setup command: 'install_requires' must be a string or list of strings containing valid project/version requirement specifiers; Expected version spec in singledispatch; python_version < "3.4" at ; python_version < "3.4"
    ----------------------------------------
ERROR: Command "python setup.py egg_info" failed with error code 1 in /private/tmp/pip-install-vY99RW/nltk/

Ваша помощь очень ценится! Большое спасибо от Юпитера, Флорида, США!

1 Ответ

1 голос
/ 01 июня 2019

Попробуйте запустить sudo -H pip3 install -U nltk

...