Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python Import Issues - Windows Build #1257

Open
Gronchii opened this issue Jul 31, 2024 · 2 comments
Open

Python Import Issues - Windows Build #1257

Gronchii opened this issue Jul 31, 2024 · 2 comments
Labels
Windows This is about support on the Windows platform

Comments

@Gronchii
Copy link

I have managed to get this to build successfully on windows after some changes for MSVC, but I am not able to import into python. I followed the windows build guide and added the 2 paths to my PYTHONPATH:

-D:\OpenSpiel\open_spiel\open_spiel\out\build\x64-Debug
-D:\OpenSpiel\open_spiel\open_spiel\out\build\x64-Debug\python

However, I now have 2 issues when trying to import into python script.

The first is when I try to import pyspiel through python

import pyspiel

I get this error: ImportError: DLL load failed while importing pyspiel: The specified module could not be found.

I do see where pyspiel.pyd is present inside build\x64-Debug\python, and when I remove from PYTHONPATH it no longer is able to find the module at all.

The second python issue is when I try to run open_spiel\python\examples\example.py I get a different error relating to attempting to import from open_spiel.python

Traceback (most recent call last): File "d:\OpenSpiel\open_spiel\open_spiel\python\examples\example.py", line 24, in <module> from open_spiel.python import games # pylint: disable=unused-import ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ModuleNotFoundError: No module named 'open_spiel'

Any insight would be appreciated

@lanctot lanctot added the Windows This is about support on the Windows platform label Aug 1, 2024
@lanctot
Copy link
Collaborator

lanctot commented Aug 1, 2024

For the second problem, I think you also need to have the top-level source directory as well in PYTHONPATH, e.g. the equivalents of step 5 in these instructions: https://github.com/google-deepmind/open_spiel/blob/master/docs/install.md#summary

Based on your paths above that would be D:\OpenSpiel\open_spiel\open_spiel.

For the first problem, I don't know how to solve it. If the DLL is being built and it's in the PYTHONPATH then Python should be able to load it. Possibly Python is not setup to look into the PYTHONPATH, but that worked for me last time I tried it.

@Gronchii
Copy link
Author

Gronchii commented Aug 1, 2024

You are correct, adding top-level did resolve the open_spiel.python import. The pyspiel import issue looks to be due to conda, the dll loads fine when run outside of a conda environment so I will see if I can get that sorted

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Windows This is about support on the Windows platform
Projects
None yet
Development

No branches or pull requests

2 participants