SteamworksPy: FileNotFoundError: Could not find module '...\my_project\SteamworksPy.dll'

When I try to get started with SteamworksPy I get the following FileNotFoundError, even though the SteamworksPy.dll file is in the specified path:

C:\Users\andre\AppData\Local\Programs\Python\Python38-32\python.exe C:/Users/andre/PycharmProjects/my_project/steamworks_example.py
Traceback (most recent call last):
  File "C:/Users/andre/PycharmProjects/my_project/steamworks_example.py", line 17, in <module>
    steamworks = STEAMWORKS()
  File "C:\Users\andre\PycharmProjects\my_project\steamworks\__init__.py", line 50, in __init__
    self._initialize()
  File "C:\Users\andre\PycharmProjects\my_project\steamworks\__init__.py", line 90, in _initialize
    self._cdll 		= CDLL(library_path) # Throw native exception in case of error
  File "C:\Users\andre\AppData\Local\Programs\Python\Python38-32\lib\ctypes\__init__.py", line 373, in __init__
    self._handle = _dlopen(self._name, mode)
FileNotFoundError: Could not find module 'C:\Users\andre\PycharmProjects\my_project\SteamworksPy.dll'. Try using the full path with constructor syntax.

Process finished with exit code 1

I am using 32 bit Python 3.8, and after some research I suspect it has something to do with this (which of course I tried and could not get to work either…):

https://stackoverflow.com/a/59016932

It goes past the raised exceptions regarding missing library and missing steam_appid.txt and I believe all the files are in the correct places.

Any help appreciated 😃

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 15 (4 by maintainers)

Most upvoted comments

So these are the files at the top level of my project:

steamworks (entire dir)
steam_api.lib (from the latest Steamworks SDK)
steam_appid.txt (with my app id)
steamworks_example.py (your example/__init__ file which I renamed and placed top level)
SteamworksPy.dll (from the releases section in the repo)

Well, I just noticed you are missing the steam_api[64].dll in your working directory.

FileNotFoundError: Could not find module... will also be thrown if one of the modules in the dependency tree does not exist or could not be located with the new restrictions in place.

import os
os.add_dll_directory(os.getcwd())

from steamworks import STEAMWORKS

steamworks = STEAMWORKS()
steamworks.initialize()

my_steam64 = steamworks.Users.GetSteamID()
my_steam_level = steamworks.Users.GetPlayerSteamLevel()

print(f'Logged on as {my_steam64}, level: {my_steam_level}')

add_dll_directory must be called before the actual module is imported afaik. I do not have a 3.8 installation on hand right now, but this should work.

Yeah, the documentation is pretty outdated as it hasn’t been updated since the module change. I haven’t had the time to go through it and document the process from beginning to end yet.

That layout looks right to me, but currently my knowledge is limited. @philippj would know better.

Currently, the DLL must be in the current working directory (https://github.com/Gramps/SteamworksPy/blob/master/steamworks/__init__.py#L79)

So adding a os.add_dll_directory(os.getcwd()) should do the trick for you.