Search code examples
pythonwxpython

wxPython import work with cmd but not within a *.py


Good day,

I just started to work with wxpython for a few more features then tkinter, but ran into a problem. I installed wxpython via pip without errors.

Now the following code work if I type it to Windows cmd

import wx

app = wx.App()

frame = wx.Frame(None, title="Simple")
frame.Show()

app.MainLoop()

but if I use F:\guiwx.py i got:

  File "F:\guiwx.py", line 1, in <module>
    import wx
ModuleNotFoundError: No module named 'wx'

Even after reinstall the problem stays the same.

I have only one version of Python installed (2.7.15) which I need for work.

What is going wrong here?


Solution

  • Just use the command:

    python F:\guiwx.py
    

    and it should work.