pip install easyAI
from easyAI import TwoPlayersGame, id_solve, Human_Player, AI_Player
from easyAI.AI import TT
ImportError:無法從“easyAI”(/usr/local/lib/python3.7/dist-packages/easyAI/__init__.py)匯入名稱“TwoPlayersGame”
uj5u.com熱心網友回復:
其實只是打錯了,應該用TwoPlayerGame替換TwoPlayersGame。
通常,您可以使用dir以下方式獲取物件中的引數:
Python 3.7.12 (default, Sep 28 2021, 19:43:27)
[GCC 10.2.1 20210110] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import easyAI
>>> dir(easyAI)
['AI', 'AI_Player', 'DUAL', 'DictTranspositionTable', 'HashTranspositionTable', 'Human_Player', 'Negamax', 'NonRecursiveNegamax', 'Player', 'SSS', 'TranspositionTable', 'TwoPlayerGame', '__all__', '__builtins__', '__cached__', '__doc__', '__file__', '__loader__', '__name__', '__package__', '__path__', '__spec__', 'mtd', 'solve_with_depth_first_search', 'solve_with_iterative_deepening']
>>> from easyAI import TwoPlayerGame
uj5u.com熱心網友回復:
如果您安裝了 pip,您可以在終端中鍵入它
sudo pip install easyAI。否則,請下載源代碼(例如在 Github 上),將所有內容解壓縮到一個檔案夾中,然后在此檔案夾中的終端中輸入sudo python setup.py install. 那你可以試試
from easyAI import TwoPlayerGame, Human_Player, AI_Player, Negamax
轉載請註明出處,本文鏈接:https://www.uj5u.com/net/507967.html
標籤:Python python-3.x python-2.7 进口 导入错误
