【问题标题】:Pip install indexer error in Python3 Windows 10Python3 Windows 10 中的 Pip 安装索引器错误
【发布时间】:2020-08-11 17:13:36
【问题描述】:

我从 git 存储库克隆的应用程序需要在应用程序中使用模块 indexer。所以我使用python3 安装indexer

python3 -m pip install indexer //this is equal to pip3 install indexer*

但是它会产生这个错误:

我搜索了一下,得到了this stackoverflow question的答复。

所以看来这是一个来自不同的不同语法的问题 python版本。

我尝试使用python2 安装它,它可以工作。但由于我使用python3 运行它,我搜索了另一个与python3 兼容的indexer 模块,我找到了python3-lzo-indexer 并尝试安装它。但是当我用python3 运行它时,它仍然缺少模块indexer

如何使用python3 安装索引器?

有人已经在stackoverflow上问过here,但仍然没有解决办法

*) 我使用上面的命令是因为我在我的机器上安装了双版本的 python(python2python3)。即使不是这样。

【问题讨论】:

  • 您实际上可以通过更改setup.py 中的几行来将其安装在python 3 上。安装后它是否有效是另一个问题。
  • @Axe319 我需要更改哪些行以及如何更改?你有参考吗?
  • 我会添加它作为答案。

标签: python python-3.x


【解决方案1】:

重新安装 Python 并重试。我试图重现这个错误。

尝试安装索引器:

Collecting indexer
  Downloading indexer-0.6.2.tar.gz (14 kB)
    ERROR: Command errored out with exit status 1:
     command: 'c:\users\fatalcoder524\appdata\local\programs\python\python37\python.exe' -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\fatalcoder524\\AppData\\Local\\Temp\\pip-install-btasoark\\indexer\\setup.py'"'"'; __file__='"'"'C:\\Users\\fatalcoder524\\AppData\\Local\\Temp\\pip-install-btasoark\\indexer\\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 'C:\Users\fatalcoder524\AppData\Local\Temp\pip-install-btasoark\indexer\pip-egg-info'
         cwd: C:\Users\fatalcoder524\AppData\Local\Temp\pip-install-btasoark\indexer\
    Complete output (6 lines):
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "C:\Users\fatalcoder524\AppData\Local\Temp\pip-install-btasoark\indexer\setup.py", line 107
        except OSError, ex:
                      ^
    SyntaxError: invalid syntax
    ----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.

尝试安装 python3-lzo-indexer:

Collecting python3-lzo-indexer
  Downloading python3_lzo_indexer-0.3.0-py2.py3-none-any.whl (6.6 kB)
Requirement already satisfied: click==7.0 in c:\users\fatalcoder524\appdata\local\programs\python\python37\lib\site-packages (from python3-lzo-indexer) (7.0)
Installing collected packages: python3-lzo-indexer
Successfully installed python3-lzo-indexer-0.3.0

尝试使用python -m "import lzo_indexer" 使用索引器:

C:\Users\fatalcoder524\AppData\Local\Programs\Python\Python37\python.exe: No module named import lzo_indexer

尝试在python解释器中执行:

Python 3.7.0b3 (v3.7.0b3:4e7efa9c6f, Mar 29 2018, 18:42:04) [MSC v.1913 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import lzo_indexer
>>> dir(lzo_indexer)
['__builtins__', '__cached__', '__doc__', '__file__', '__loader__', '__name__', '__package__', '__path__', '__spec__', 'get_lzo_blocks', 'index_lzo_file', 'indexer']

【讨论】:

  • 我已经重新安装了python并再次尝试,但没有任何效果
【解决方案2】:

运行python3 -m pip install indexer 会出现此错误。

Collecting indexer
  Downloading https://files.pythonhosted.org/packages/c7/2f/49ea001ccc81502fe790c6077ca0cf9c4dc98ce160e1b1225a8c881b53b1/indexer-0.6.2.tar.gz
    ERROR: Command errored out with exit status 1:
     command: 'c:\users\mike\projects\test\scripts\python.exe' -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\Mike\\AppData\\Local\\Temp\\pip-install-o8rly6_7\\indexer\\setup.py'"'"'; __file__='"'"'C:\\Users\\Mike\\AppData\\Local\\Temp\\pip-install-o8rly6_7\\indexer\\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 pip-egg-info
         cwd: C:\Users\Mike\AppData\Local\Temp\pip-install-o8rly6_7\indexer\
    Complete output (6 lines):
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "C:\Users\Mike\AppData\Local\Temp\pip-install-o8rly6_7\indexer\setup.py", line 107
        except OSError, ex:
                      ^
    SyntaxError: invalid syntax
    ----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.

Downloading 行显示了它的下载位置,因此您可以从那里下载tar.gz 并解压缩它。 在基本文件夹中,您应该会看到一个 setup.py 文件。 上一个错误的 Traceback 可以很好地提示错误发生的位置。 这一行

except OSError, ex:

是无效的 python 3 语法并转换为

except OSError as ex:

在 python 3 中。

因此,您需要将行 107116 更改为该行,因为它们都有相同的语法错误。 此外,还有一个需要更改的导入。 将行 14

from os.path import isdir, exists, join, walk

到这里

from os.path import isdir, exists, join

并像这样在其下方添加另一行

from os import walk

在 python 3 中,walk 直接从 os 模块内部调用。

保存后,您可以运行python3 -m pip install &lt;path to base folder&gt;,其中&lt;path to base folder&gt;setup.py 所在的文件夹。

免责声明:

这只会为您提供部分帮助,因为此软件包适用于 python 2。

安装后,我可以在Lib\site-packages\indexer\postgres8_indexer.pyLib\site-packages\indexer\search.py 和其他地方看到python 2 print 语句的一些实例。这些显然可以在您遇到它们时进行更改,但很可能还有其他更细微的语法差异。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-02-20
    • 2017-08-23
    • 1970-01-01
    • 1970-01-01
    • 2017-05-24
    • 2016-01-11
    • 1970-01-01
    • 2020-04-27
    相关资源
    最近更新 更多