繁体   English   中英

Pip 在 Python3 中安装索引器错误 Windows 10

[英]Pip install indexer error in Python3 Windows 10

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

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

但是它会产生此错误:

错误

我搜索它,我从这个 stackoverflow 问题中得到了答案。

因此,与不同的 python 版本不同的语法似乎是一个问题。

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

如何使用python3安装索引器?

有人已经在这里问过stackoverflow,但仍然没有解决方案

*) 我使用了上面的命令,因为我在我的机器上安装了 python( python2python3 )的双版本。 即使情况并非如此。

重新安装 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']

运行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。

因此,您需要将第107行和116行更改为该行,因为它们都有相同的语法错误。 此外,还有一个需要更改的导入。 将第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 <path to base folder>其中<path to base folder>setup.py所在的文件夹。

免责声明:

这只会让您部分获得成功,因为此 package 适用于 python 2。

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

暂无
暂无

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

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