ApproxEng / approxeng.input

Python classes to handle game controllers, including PS3, PS4, XBox One and Rock Candy
https://approxeng.github.io/approxeng.input
Apache License 2.0
55 stars 17 forks source link

ModuleNotFoundError when importing Controller Resource #45

Closed adonis-thr closed 3 years ago

adonis-thr commented 3 years ago

Hello,

This is an issue that just started happening this past month. I've been using your library for interfacing with a PS4 controller since November and it was working well.

Very recently, I've been getting the following error when attempting to import the library in the following format: from approxeng.input.selectbinder import ControllerResrouce

I now get the following error:

File "PS4BT2.py", line 15, in <module>
  from approxeng.input.selectbinder import ControllerResource
File "/home/nvidia/.local/lib/python3.6/site-packages/approxeng/input/selectbinder.py", line 6, in <module>
  from approxeng.input.controllers import *
File "/home/nvidia/.local/lib/python3.6/site-packages/approxeng/input/controllers.py", line 1, in <module>
  import importlib.resources as resources
ModuleNotFoundError: No module named 'importlib.resources

This is similar code that I copied from the example on Brian Corteil's Tiny 4WD robot as shown in the doc: https://approxeng.github.io/approxeng.input/examples/tiny4wd.html

Thanks!

tomoinn commented 3 years ago

Interesting. 3.6 is quite old, it's possible importlib isn't available in that version, I'll take a look tomorrow.

On Mon, 1 Feb 2021, 23:02 adonis-thr, notifications@github.com wrote:

Hello,

This is an issue that just started happening this past month. I've been using your library for interfacing with a PS4 controller since November and it was working well.

Very recently, I've been getting the following error when attempting to import the library in the following format: from approxeng.input.selectbinder import ControllerResrouce

I now get the following error: File "PS4BT2.py", line 15, in from approxeng.input.selectbinder import ControllerResource File "/home/nvidia/.local/lib/python3.6/site-packages/approxeng/input/selectbinder.py", line 6, in from approxeng.input.controllers import * File "/home/nvidia/.local/lib/python3.6/site-packages/approxeng/input/controllers.py", line 1, in import importlib.resources as resources ModuleNotFoundError: No module named 'importlib.resources

This is similar code that I copied from the example on Brian Corteil's Tiny 4WD robot as shown in the doc: https://approxeng.github.io/approxeng.input/examples/tiny4wd.html

Thanks!

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/ApproxEng/approxeng.input/issues/45, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAKV2BW6AYBN4BPYY4FZBATS44XHZANCNFSM4W5TTYTQ .

adonis-thr commented 3 years ago

Thanks!

tomoinn commented 3 years ago

Quick thing to try, can you see if installing 'importlib-resources' with pip fixes it?

On Mon, 1 Feb 2021, 23:23 adonis-thr, notifications@github.com wrote:

Thanks!

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/ApproxEng/approxeng.input/issues/45#issuecomment-771230725, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAKV2BQMWW3OBNBVPXWB5KDS44ZX5ANCNFSM4W5TTYTQ .

adonis-thr commented 3 years ago

It still didn't seem to work. If its an issue with python3.6, then I can just update it to the latest version.

adonis-thr commented 3 years ago

It looks like I was able to fix the issue by changing the import package in "approxeng/input/controllers.py" to: import importlib_resources as resources from import importlib.resources as resources

This might be something specific to the library itself when using python 3.6 when looking at their doc: https://importlib-resources.readthedocs.io/en/latest/using.html

tomoinn commented 3 years ago

This should hopefully have fixed it - I'd still suggest updating to a more recent Python just because there's a lot of good stuff in newer versions, but hopefully if you now do 'pip install approxeng.input --upgrade' it should pick up the new version, install the backport, and work properly again?

adonis-thr commented 3 years ago

Thanks, all working well :)