无法安装Pattern包(操作系统Bash终端)

huangapple go评论132阅读模式
英文:

Unable to install Pattern Package (OS Bash Terminal)

问题

我无法安装Pattern包。请提供帮助!!

  1. lucy$ pip3 install pattern
  2. Collecting pattern
  3. Using cached https://files.pythonhosted.org/packages/1e/07/b0e61b6c818ed4b6145fe01d1c341223aa6cfbc3928538ad1f2b890924a3/Pattern-3.6.0.tar.gz
  4. Collecting future
  5. Using cached https://files.pythonhosted.org/packages/45/0b/38b06fd9b92dc2b68d58b75f900e97884c45bedd2ff83203d933cf5851c9/future-0.18.2.tar.gz
  6. Collecting backports.csv
  7. Using cached https://files.pythonhosted.org/packages/8e/26/a6bd68f13e0f38fbb643d6e497fc3462be83a0b6c4d43425c78bb51a7291/backports.csv-1.0.7-py2.py3-none-any.whl
  8. Collecting mysqlclient
  9. Using cached https://files.pythonhosted.org/packages/d0/97/7326248ac8d5049968bf4ec708a5d3d4806e412a42e74160d7f266a3e03a/mysqlclient-1.4.6.tar.gz
  10. ERROR: Command errored out with exit status 1:
  11. command: /Library/Frameworks/Python.framework/Versions/3.7/bin/python3.7 -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/dg/3dc4wnvn2ll0bz4p781nw1jc0000gn/T/pip-install-v1dttx0k/mysqlclient/setup.py'"'"'; __file__='"'"'/private/var/folders/dg/3dc4wnvn2ll0bz4p781nw1jc0000gn/T/pip-install-v1dttx0k/mysqlclient/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /private/var/folders/dg/3dc4wnvn2ll0bz4p781nw1jc0000gn/T/pip-install-v1dttx0k/mysqlclient/pip-egg-info
  12. cwd: /private/var/folders/dg/3dc4wnvn2ll0bz4p781nw1jc0000gn/T/pip-install-v1dttx0k/mysqlclient/
  13. Complete output (12 lines):
  14. /bin/sh: mysql_config: command not found
  15. /bin/sh: mariadb_config: command not found
  16. /bin/sh: mysql_config: command not found
  17. Traceback (most recent call last):
  18. File "<string>", line 1, in <module>
  19. File "/private/var/folders/dg/3dc4wnvn2ll0bz4p781nw1jc0000gn/T/pip-install-v1dttx0k/mysqlclient/setup.py", line 16, in <module>
  20. metadata, options = get_config()
  21. File "/private/var/folders/dg/3dc4wnvn2ll0bz4p781nw1jc0000gn/T/pip-install-v1dttx0k/mysqlclient/setup_posix.py", line 61, in get_config
  22. libs = mysql_config("libs")
  23. File "/private/var/folders/dg/3dc4wnvn2ll0bz4p781nw1jc0000gn/T/pip-install-v1dttx0k/mysqlclient/setup_posix.py", line 29, in mysql_config
  24. raise EnvironmentError("%s not found" % (_mysql_config_path,))
  25. OSError: mysql_config not found
  26. ----------------------------------------
  27. ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
  28. (base) n20286z185l10:assortedcodes lucy$
英文:

I am unable to install the Pattern package. Please kindly offer help!!

  1. lucy$ pip3 install pattern
  2. Collecting pattern
  3. Using cached https://files.pythonhosted.org/packages/1e/07/b0e61b6c818ed4b6145fe01d1c341223aa6cfbc3928538ad1f2b890924a3/Pattern-3.6.0.tar.gz
  4. Collecting future
  5. Using cached https://files.pythonhosted.org/packages/45/0b/38b06fd9b92dc2b68d58b75f900e97884c45bedd2ff83203d933cf5851c9/future-0.18.2.tar.gz
  6. Collecting backports.csv
  7. Using cached https://files.pythonhosted.org/packages/8e/26/a6bd68f13e0f38fbb643d6e497fc3462be83a0b6c4d43425c78bb51a7291/backports.csv-1.0.7-py2.py3-none-any.whl
  8. Collecting mysqlclient
  9. Using cached https://files.pythonhosted.org/packages/d0/97/7326248ac8d5049968bf4ec708a5d3d4806e412a42e74160d7f266a3e03a/mysqlclient-1.4.6.tar.gz
  10. ERROR: Command errored out with exit status 1:
  11. command: /Library/Frameworks/Python.framework/Versions/3.7/bin/python3.7 -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/dg/3dc4wnvn2ll0bz4p781nw1jc0000gn/T/pip-install-v1dttx0k/mysqlclient/setup.py'"'"'; __file__='"'"'/private/var/folders/dg/3dc4wnvn2ll0bz4p781nw1jc0000gn/T/pip-install-v1dttx0k/mysqlclient/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /private/var/folders/dg/3dc4wnvn2ll0bz4p781nw1jc0000gn/T/pip-install-v1dttx0k/mysqlclient/pip-egg-info
  12. cwd: /private/var/folders/dg/3dc4wnvn2ll0bz4p781nw1jc0000gn/T/pip-install-v1dttx0k/mysqlclient/
  13. Complete output (12 lines):
  14. /bin/sh: mysql_config: command not found
  15. /bin/sh: mariadb_config: command not found
  16. /bin/sh: mysql_config: command not found
  17. Traceback (most recent call last):
  18. File "<string>", line 1, in <module>
  19. File "/private/var/folders/dg/3dc4wnvn2ll0bz4p781nw1jc0000gn/T/pip-install-v1dttx0k/mysqlclient/setup.py", line 16, in <module>
  20. metadata, options = get_config()
  21. File "/private/var/folders/dg/3dc4wnvn2ll0bz4p781nw1jc0000gn/T/pip-install-v1dttx0k/mysqlclient/setup_posix.py", line 61, in get_config
  22. libs = mysql_config("libs")
  23. File "/private/var/folders/dg/3dc4wnvn2ll0bz4p781nw1jc0000gn/T/pip-install-v1dttx0k/mysqlclient/setup_posix.py", line 29, in mysql_config
  24. raise EnvironmentError("%s not found" % (_mysql_config_path,))
  25. OSError: mysql_config not found
  26. ----------------------------------------
  27. ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
  28. (base) n20286z185l10:assortedcodes lucy$

答案1

得分: 0

Pattern支持Python 2.7和Python 3.6。请参考 https://github.com/clips/pattern#pattern
这对我来说在Python 3.6中让pattern.en工作:

  1. git clone -b development https://github.com/clips/pattern
  2. cd pattern
  3. sudo python3.6 setup.py install

在我的mac (10.11.6) 安装过程中,我遇到了一些SSL错误,通过在Python (3.6) 中运行以下代码来解决:

  1. import nltk
  2. import ssl
  3. try:
  4. _create_unverified_https_context = ssl._create_unverified_context
  5. except AttributeError:
  6. pass
  7. else:
  8. ssl._create_default_https_context = _create_unverified_https_context
  9. nltk.download('wordnet_ic')

显然,有一种更好的方式来处理类似这样的SSL问题,详见:https://stackoverflow.com/a/41351871/8870055。

健全性检查:

  1. user@USDR00253 ~> python3.6
  2. Python 3.6.4 (v3.6.4:d48ecebad5, Dec 18 2017, 21:07:28)
  3. [GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
  4. Type "help", "copyright", "credits" or "license" for more information.
  5. >>>
  6. >>> from pattern.en import conjugate, lemma, lexeme, parse
  7. >>>
  8. >>> print(parse('ridden', relations=True, lemmata=True))
  9. ridden/VBN/B-VP/O/O/ride
  10. >>>

pattern.en最终在Python 3中运行成功!

英文:

Pattern supports Python 2.7 and Python 3.6.
Kindly refer https://github.com/clips/pattern#pattern.
This worked for me to get pattern.en working in python 3.6:

  1. git clone -b development https://github.com/clips/pattern
  2. cd pattern
  3. sudo python3.6 setup.py install

I had some SSL errors during installation on my mac (10.11.6) that were fixed by running this code in python (3.6):

  1. import nltk
  2. import ssl
  3. try:
  4. _create_unverified_https_context = ssl._create_unverified_context
  5. except AttributeError:
  6. pass
  7. else:
  8. ssl._create_default_https_context = _create_unverified_https_context
  9. nltk.download('wordnet_ic')

apparently there's a better way to deal with ssl stuff like this fwiw: https://stackoverflow.com/a/41351871/8870055

sanity check:

  1. user@USDR00253 ~> python3.6
  2. Python 3.6.4 (v3.6.4:d48ecebad5, Dec 18 2017, 21:07:28)
  3. [GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
  4. Type "help", "copyright", "credits" or "license" for more information.
  5. >>>
  6. >>> from pattern.en import conjugate, lemma, lexeme, parse
  7. >>>
  8. >>> print(parse('ridden', relations=True, lemmata=True))
  9. ridden/VBN/B-VP/O/O/ride
  10. >>>

pattern.en finally running in python 3!

huangapple
  • 本文由 发表于 2020年1月6日 18:56:17
  • 转载请务必保留本文链接:https://go.coder-hub.com/59610832.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定