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

Receiving "No methods for platform 'windows'!" on Windows 11 in script #90

Open
Jackio007 opened this issue Jun 17, 2023 · 2 comments
Open
Assignees
Labels

Comments

@Jackio007
Copy link

Jackio007 commented Jun 17, 2023

Describe the bug
I receive a RuntimeWarning error when executing function through Python, but it's fine when running through the terminal.

Expected behavior
I am on a Windows platform, so Python should use the windows module, like it does from the terminal.

System info
(please complete the following information):

  • OS name (e.g. Windows 10 x64): Windows 11 x64
  • OS Version (e.g. 1804 build 17134): 22H2 22631.1835
  • Python version (e.g. CPython 3.6.5 x64): Python 3.9.13
  • getmac version (e.g. getmac 0.8.3): getmac 0.9.4

Additional context
When running get_mac_address(interface="WiFi") in Python, I get the following output:
C:\Users\User\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\getmac\getmac.py:1441: RuntimeWarning: No methods for platform 'windows'! Your system may not be supported. Falling back to platform 'other'.
warnings.warn(warn_msg, RuntimeWarning)

04:6c:59:0f:10:40

However, when running via the terminal I get the following, confirming platform is windows:

python -m getmac -v -d
DEBUG Initializing 'ip4' method cache (platform: 'windows')
DEBUG Current method cache: {'ip4': 'CtypesHost', 'ip6': 'None', 'iface': 'None', 'default_iface': 'None'}
DEBUG Current fallback cache: {'ip4': '[<getmac.getmac.ArpExe object at 0x0000029C0C921D90>]', 'ip6': '[]', 'iface': '[]', 'default_iface': '[]'}
DEBUG Finished initializing 'ip4' method cache
DEBUG Attempting get() (method='CtypesHost', method_type='ip4', arg='192.168.0.136')
DEBUG Raw MAC found: 046c590f1040
DEBUG getmac took 0.0028 seconds
DEBUG Adding colons to MAC 046c590f1040

(This is my first ever issue, so apologies if there is anything missed)

@GhostofGoes
Copy link
Owner

Hey @Jackio007, thanks for reporting this issue (and you got everything, thanks for following the template 😉 ). This is definitely unusual behavior, and somewhat surprising considering I primarily develop on Windows 11 machines, so I thought I'd have noticed it by now. I'll take a look at it after work tomorrow and see if I can reproduce.

In the immediate short term, you should be able to force the platform by setting getmac.getmac.platform = "windows" before calling the function.

@GhostofGoes GhostofGoes self-assigned this Jun 23, 2023
@GhostofGoes
Copy link
Owner

Apologies for the delay. This is definitely a bug I was able to reproduce. Just to confirm, do you also get 04:6c:59:0f:10:40 when running getmac -v -d -i 'Wi-Fi'?

What seems to be happening is the default interface isn't being determined properly. On my Windows 11 laptop, if I run getmac -v -d (no interface specified), it returns the MAC for "Microsoft Wi-Fi Direct Virtual Adapter", when it should be returning the MAC for "Wi-Fi", as that's the default interface.

Not sure why this is happening, I'll look into it further and get working on a fix. The silver lining is the code for finding the default interface on Windows has needed work for a while and this is a good excuse to finally clean it up properly 😅

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants