安装特定版本“chess不是包”的包时出现Python问题

安装特定版本“chess不是包”的包时出现Python问题,python,python-3.x,package,python-import,Python,Python 3.x,Package,Python Import,因此,我尝试在我的服务器中使用PUTTY来安装chess python包。 服务器有Python2.6和Python3.4。 国际象棋pakcage仅适用于3.4 因此,要安装它,我运行: python3 -m pip install python-chess 答复: Requirement already satisfied: python-chess in /home/egqbe6ns/.local/lib/python3.4/site-packages (0.27.3) 脚本Chess

因此,我尝试在我的服务器中使用PUTTY来安装chess python包。 服务器有Python2.6和Python3.4。 国际象棋pakcage仅适用于3.4

因此,要安装它,我运行:

python3 -m pip install python-chess
答复:

Requirement already satisfied: python-chess in /home/egqbe6ns/.local/lib/python3.4/site-packages (0.27.3)
脚本Chess.py:

import chess
import chess.engine

fen = 'r2qkb1r/1p1bpp1p/p1n2p2/8/B1pP4/5N2/P1P2PPP/RN1QK2R w KQkq - 0 12'
board = chess.Board(fen)
handler = chess.uci.InfoHandler()
使用python3 chess.py 2>&1运行脚本时:


看起来您已将脚本命名为chess.py。默认情况下,模块将在其中搜索sys.path的标准目录包括当前目录,因此import chess会将脚本作为模块加载。显然,它不包含子模块引擎


只需将脚本重命名为其他名称,删除文件chess.pyc(如果存在),然后重试

great,但现在我得到了以下信息:导入chess ImportError中的文件chess2.py,第1行:“chess”中的错误幻数:b'\xd1\xf2\r\n'是否删除了chess.pyc文件?
Traceback (most recent call last):
  File "<frozen importlib._bootstrap>", line 2218, in _find_and_load_unlocked
AttributeError: 'module' object has no attribute '__path__'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "chess.py", line 1, in <module>
    import chess
  File "/home/egqbe6ns/public_html/chess.py", line 2, in <module>
    import chess.engine
ImportError: No module named 'chess.engine'; 'chess' is not a package
pip --version
pip 19.1.1 from /home/egqbe6ns/.local/lib/python3.4/site-packages/pip (python 3.4)

python3 --version
Python 3.4.3