0

I’ve downloaded pygame but VS code says, in the problems section , it is “Unable to import ’pygame’ pylint(import-error)” In the terminal it says “ModuleNotFoundError: No module named ‘pygame’”

What could be causing it to not import?

Edit: I added some more specifics

  • Try use it within virtual environment – pl-jay Feb 27 '21 at 03:33
  • I don’t understand what to do from the question you posted. Do you think you could explain it to me? Sorry and thanks. I’m not to well versed in Visual studio so I don’t know a lot about it. – Cooper Boling Feb 27 '21 at 03:37

1 Answers1

1

I'm pretty new to python, but I'll try to give you a solution.

You could create a virtual environment in your terminal. If you don't know how to do that, here's a link to a website I found for macos, https://sourabhbajaj.com/mac-setup/Python/virtualenv.html. For windows, https://mothergeo-py.readthedocs.io/en/latest/development/how-to/venv-win.html. Activate the virtualenv, and then pip install pygame inside the virtualenv, so when you run your code, pygame should work as long as the virtualenv you downloaded pygame in is activated.

I really hope this helps as this is my first time answering a question on stackoverflow!

GrrTaco
  • 11
  • 1
  • I’m having trouble create the virtual environment. Do I type in the VS terminal? Cause if I do, when I typed the command for creating the environment it says “Set-Location : A positional parameter cannot be found that accepts argument ‘virtualenv’.” – Cooper Boling Feb 27 '21 at 04:28
  • Never mind, my brain clicked some of the pieces. I’ll update my findings – Cooper Boling Feb 27 '21 at 04:32
  • @CooperBoling, you can use your regular terminal on your computer to create the virtual environments and you can try activating your environment in the vs code terminal. – GrrTaco Feb 27 '21 at 04:42
  • Thank you. I’ll try this tomorrow I’m a little fed up with it. – Cooper Boling Feb 27 '21 at 05:09