簡體   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