0

I made a program using pygame and I can run it on IDLE but not on Sublime Text. When I run it on sublime it outputs that error message.

Traceback (most recent call last):
  File "/Users/Milos/Desktop/Hangman/hangman.py", line 1, in <module>
    import pygame2
ImportError: No module named pygame2
[Finished in 0.1s with exit code 1]
[shell_cmd: python -u "/Users/Milos/Desktop/Hangman/hangman.py"]
[dir: /Users/Milos/Desktop/Hangman]
[path: /Library/Frameworks/Python.framework/Versions/3.8/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin]

this happens every time I try to import a library on any program

1000 os
  • 1
  • 1
  • Hello! It's possible that SublimeText is looking at a wrong version of Python. Take a look at [This guide](https://medium.com/@hariyanto.tan95/set-up-sublime-text-3-to-use-python-3-c845b742c720) to set up the program. – NotAName Jun 25 '20 at 01:10

1 Answers1

1

That happens when you use the programs with different Python interpreters, if you have multiple versions of Python installed on your computer, for example if you have Anaconda installed, its interpreter will have most modules installed, but the default Python downloads only have a handfull. You will probably need to create a new build system for Python on sublime, and select the interpreter that has the modules you've installed, here are a few links that might help:

https://askubuntu.com/questions/1103987/how-to-change-python-version-in-sublime-ubuntu-18

How to change the default Python interpreter in Sublime text 3

https://forum.sublimetext.com/t/select-which-version-of-python-to-run-build/1695