getting an import statement to work in my program - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: getting an import statement to work in my program (/thread-35726.html) |
getting an import statement to work in my program - barryjo - Dec-06-2021 I have installed PyCharm as my python IDE. Previously, I (think) I installed a module pygame that has USB joystick interfaces. In my program,I want to insert the import statement but am having errors. I have inserted import pygame and get a module not found error. so, I know the directory where pygame was installed.. C:/users/barry so I am trying import C:/users/barry and this doesn't work. What am I doing wrong?? I have tried c\users\barry\pygame.py and a few other attempts so how do I get pygame imported? Thanks RE: getting an import statement to work in my program - snippsat - Dec-06-2021 Did you read my last post where i try to explain how this work? So to to add some info will install pygame and test that it work,all from cmd .# Test python C:\>python -V Python 3.9.5 # Test pip C:\>pip -V pip 21.2.4 from c:\python39\lib\site-packages\pip (python 3.9) # Install C:\>pip install pygame --upgrade Collecting pygame Downloading pygame-2.1.0-cp39-cp39-win_amd64.whl (4.8 MB) |████████████████████████████████| 4.8 MB 1.3 MB/s Installing collected packages: pygame Successfully installed pygame-2.1.0 # Test that it work C:\>python Python 3.9.5 (tags/v3.9.5:0a7dcbd, May 3 2021, 17:27:52) [MSC v.1928 64 bit (AM D64)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import pygame pygame 2.1.0 (SDL 2.0.16, Python 3.9.5) Hello from the pygame community. https://www.pygame.org/contribute.html >>> >>> pygame.__version__ '2.1.0' >>> exit() C:\>So when all work from command line in Configure a Python interpreter choose same version as interpreter, so the root path that pip -V show,eg for me c:\python39 for you it will shown and other path.Then will Pygame work in PyCharm. |