如何在 PyCharm 中正确导入 libtcod?
How to properly import libtcod in PyCharm?
我正在尝试建立一个 roguelike Python 项目,但我似乎无法将 libtcod 模块导入到我的项目中。这个 helloworld 崩溃了,IDE 一直告诉我没有名为 libtcodpy 的模块。
import libtcodpy
def main():
print('Hello World!')
if __name__ == '__main__':
main()
将模块导入 Python 项目的正确方法是什么?我已经习惯了 Java,所以我期待使用 Maven 的方式来管理依赖项。在 PyCharm 中确实也有类似的东西,这个 venv 的包管理器,根据我收集的信息,它用于将项目特定的东西与 OS- 或 python-全球的东西:
但是 libtcod 根本不存在于单击“+”按钮后出现的相当详尽的模块列表中,只是一些与 libtcod 库有关的其他模块(我猜?)。此外,我发现的所有关于设置 libtcod 的教程都建议手动复制某个地方的文件或 运行 一些我认为以某种方式导入的命令和其他此类解决方案,所有这些我都尝试过并且 none其中工作。如果可以完全避免的话,我不想使用这种处理依赖关系的大杂烩方式来污染我的项目结构。
问:如何让 libtcod 以最干净、最符合约定的方式在我的 PyCharm 项目中工作?
看看这个名为 tcod 的 github 项目:https://github.com/libtcod/python-tcod/blob/master/README.rst#installation
它是 libtcod 的 python 端口。
To install using pip, use the following command:
python -m pip install tcod
If you get the error "ImportError: DLL load failed: The specified module could not be found." when trying to import tcod/tdl then you may need the latest Microsoft Visual C runtime.
Blockquote
我正在尝试建立一个 roguelike Python 项目,但我似乎无法将 libtcod 模块导入到我的项目中。这个 helloworld 崩溃了,IDE 一直告诉我没有名为 libtcodpy 的模块。
import libtcodpy
def main():
print('Hello World!')
if __name__ == '__main__':
main()
将模块导入 Python 项目的正确方法是什么?我已经习惯了 Java,所以我期待使用 Maven 的方式来管理依赖项。在 PyCharm 中确实也有类似的东西,这个 venv 的包管理器,根据我收集的信息,它用于将项目特定的东西与 OS- 或 python-全球的东西:
问:如何让 libtcod 以最干净、最符合约定的方式在我的 PyCharm 项目中工作?
看看这个名为 tcod 的 github 项目:https://github.com/libtcod/python-tcod/blob/master/README.rst#installation
它是 libtcod 的 python 端口。
To install using pip, use the following command:
python -m pip install tcod
If you get the error "ImportError: DLL load failed: The specified module could not be found." when trying to import tcod/tdl then you may need the latest Microsoft Visual C runtime. Blockquote