简体   繁体   English

来自期货的 Python PyDictionary 导入错误

[英]Python PyDictionary Import error from futures

So I run python -m pip install PyDictionary and I get this output:所以我运行python -m pip install PyDictionary并得到以下输出:

Collecting PyDictionary
  Using cached PyDictionary-2.0.1-py3-none-any.whl (6.1 kB)
Requirement already satisfied: requests in d:\python\lib\site-packages (from PyDictionary) (2.27.1)
Collecting goslate
  Using cached goslate-1.5.2.tar.gz (16 kB)
  Preparing metadata (setup.py) ... done
Requirement already satisfied: click in d:\python\lib\site-packages (from PyDictionary) (8.1.3)
Collecting bs4
  Using cached bs4-0.0.1.tar.gz (1.1 kB)
  Preparing metadata (setup.py) ... done
Collecting beautifulsoup4
  Using cached beautifulsoup4-4.11.1-py3-none-any.whl (128 kB)
Requirement already satisfied: colorama in d:\python\lib\site-packages (from click->PyDictionary) (0.4.4)
Collecting futures
  Using cached futures-3.0.5.tar.gz (25 kB)
  Preparing metadata (setup.py) ... error
  error: subprocess-exited-with-error

  × python setup.py egg_info did not run successfully.
  │ exit code: 1
  ╰─> [27 lines of output]
      Traceback (most recent call last):
        File "<string>", line 2, in <module>
        File "<pip-setuptools-caller>", line 14, in <module>
        File "D:\Python\lib\site-packages\setuptools\__init__.py", line 189, in <module>
          monkey.patch_all()
        File "D:\Python\lib\site-packages\setuptools\monkey.py", line 99, in patch_all
          patch_for_msvc_specialized_compiler()
        File "D:\Python\lib\site-packages\setuptools\monkey.py", line 169, in patch_for_msvc_specialized_compiler
          patch_func(*msvc14('_get_vc_env'))
        File "D:\Python\lib\site-packages\setuptools\monkey.py", line 149, in patch_params
          mod = import_module(mod_name)
        File "D:\Python\lib\importlib\__init__.py", line 126, in import_module
          return _bootstrap._gcd_import(name[level:], package, level)
        File "D:\Python\lib\site-packages\setuptools\_distutils\_msvccompiler.py", line 20, in <module>
          import unittest.mock
        File "D:\Python\lib\unittest\mock.py", line 26, in <module>
          import asyncio
        File "D:\Python\lib\asyncio\__init__.py", line 8, in <module>
          from .base_events import *
        File "D:\Python\lib\asyncio\base_events.py", line 18, in <module>
          import concurrent.futures
        File "C:\Users\localuser\AppData\Local\Temp\pip-install-vsl457j6\futures_9b56e18f578949cd955c2218e6840e1e\concurrent\futures\__init__.py", line 8, in <module>
          from concurrent.futures._base import (FIRST_COMPLETED,
        File "C:\Users\localuser\AppData\Local\Temp\pip-install-vsl457j6\futures_9b56e18f578949cd955c2218e6840e1e\concurrent\futures\_base.py", line 357
          raise type(self._exception), self._exception, self._traceback
                                     ^
      SyntaxError: invalid syntax
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed

× Encountered error while generating package metadata.
╰─> See above for output.

How do I fix it so I can download PyDictionary.如何修复它,以便我可以下载 PyDictionary。 I am using python 3.10.4.我正在使用 python 3.10.4。 I have saved Python onto a hard drive D: but it causes no other problems for pip.我已将 Python 保存到硬盘 D: 上,但它不会导致 pip 出现其他问题。 The main problem I can see is that there is a problem importing Futures but from my research I have found that Futures is already downloaded for python 3 but when I try to uninstall it is says skipping as futures in not installed so maybe that is the problem but I don`t know how to solve it.我可以看到的主要问题是导入 Futures 时出现问题,但根据我的研究,我发现 Futures 已经为 python 3 下载,但是当我尝试卸载时,它说因为未安装期货而跳过,所以也许这就是问题所在但我不知道如何解决它。 Anyone have any ideas?有人有想法么?

This seems to be a known issue with this package.这似乎是这个包的一个已知问题。 When issues like this occur, it is always best to go and check the official GitHub repository of the project and look through the open issues.当出现此类问题时,最好去查看项目的官方 GitHub 存储库并查看未解决的问题。

https://github.com/geekpradd/PyDictionary/issues/52#issuecomment-1105459595 https://github.com/geekpradd/PyDictionary/issues/52#issuecomment-1105459595

I don't have any privileges on this repo.我对这个 repo 没有任何特权。 But I did some debugging I think the actual issue here is that goslate depends on futures, and futures >=3.0.0 isn't installable on python3 at all.但是我做了一些调试,我认为这里的实际问题是goslate依赖于期货,而futures >=3.0.0根本无法在 python3 上安装。 The pypi page calls this out saying It does not work on Python 3 due to Python 2 syntax being used in the codebase. pypi 页面称它不适用于 Python 3,因为代码库中使用了 Python 2 语法。 Python 3 users should not attempt to install it, since the package is already included in the standard library. Python 3 用户不应尝试安装它,因为该包已包含在标准库中。 -- https://pypi.org/project/futures/ I am able to work around the issue by installing futures <3.0.0 before installing PyDictionary: -- https://pypi.org/project/futures/我可以通过在安装 PyDictionary 之前安装futures <3.0.0来解决这个问题:

Try this method but it is giving few results only.试试这个方法,但它只给出很少的结果。 This library uses dictionary.com这个库使用dictionary.com

pip install Py-Dictionary
from pydictionary import Dictionary
dict = Dictionary("lastname")

To store it somewhere in a variable将其存储在变量中的某个位置

meanings_list = dict.meanings()

synonyms_list = dict.synonyms()

antonyms_list = dict.antonyms()

To print this打印这个

dict.print_meanings()

dict.print_synonyms()

dict.print_antonyms()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM