0

I'm trying to set up a roguelike Python project, but I can't seem to be able to import libtcod module into my project. This helloworld crashes, and the IDE keeps telling me that there is no module named libtcodpy.

import libtcodpy

def main():
    print('Hello World!')


if __name__ == '__main__':
    main()

What is the proper way to import modules into Python projects? I'm used to Java, so I was expecting something along the lines of Maven to manage the dependencies. There indeed seems to be something like that in PyCharm as well, this package manager for the venv, which from what I gather serves to isolate the project-specific stuff from the OS- or python-global stuff: enter image description here but libtcod simply isn't present in the rather exhaustive list of modules that appears after clicking on the "+" button, just some other module that has something to do with libtcod library (I guess?). Moreover, all the tutorials I found on setting libtcod up advise one to manually copy over files somewhere or run some command that I suppose does the importing somehow and other such solutions, all of which i tried and none of which worked. I don't want to pollute my project structure by using such hodgepodge ways of handling dependencies if I can at all avoid it.

Q: How do I get libtcod to work in my PyCharm project in the most clean and convention-abiding way possible?

Sargon1
  • 854
  • 5
  • 17
  • 48

1 Answers1

2

Take a look at this github project called tcod: https://github.com/libtcod/python-tcod/blob/master/README.rst#installation

It's a python port of libtcod.

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

ambivalent
  • 36
  • 3
  • Thanks, didn't even know that this library existed. This worked, without the need to dissect the project manually. tcod is available through the package manager straight out of the box with PyCharm. Both libtcod and tcod are available for import after installing it from there. – Sargon1 Oct 31 '18 at 01:24