Atom can't find Pygame installation


#1

I’m using Python, with pygame installed. When I use IDLE, my pygame programs work properly. But when I run the same program on Atom, which includes the code “import pygame”, I get “ImportError: No module named pygame”.

Is there some setting I need to change in Atom so it can find the pygame install?


#2

This has nothing to do with Atom. You need to run pip install pygame from the command line in order to globally install it in your Python directory. Since IDLE doesn’t make you do that, I’m guessing that it has its own set of packages (this is not unusual, since Anaconda and Jupyter do a similar sort of thing).

When you look in IDLE’s directory structure, do you see a python.exe and a site-packages/ folder?


#3

Thanks so much for the prompt reply. you refer to a python.exe file/folder. My OS is a Mac.

I followed the online instructions for installing python and pygame, then Atom. As I said, my programs work on IDLE, but Atom can’t see the pygame file.

When you mention running “pip install pygame” from the command line, do you mean in my terminal window?

When I try that, the response is “-bash: pip command not found”.

As you can tell, I’m very much a newbie here. Any further help you can offer will be appreciated.


#4

Where are the pygame instructions?

When you mention running “pip install pygame” from the command line, do you mean in my terminal window?
When I try that, the response is “-bash: pip command not found”.
As you can tell, I’m very much a newbie here. Any further help you can offer will be appreciated.

Okay, so you’ve installed Python, but the pip executable in the Python folder isn’t being found. Why is that? Well, most likely, the Python folder isn’t on your PATH. You should use echo $PATH to verify and then add the Python folder if it’s missing.


#5

This is where I got the instructions:

If you could walk me through the exact steps necessary to add the python folder, I’d appreciate it.

Thanks again.


#6

There’s a plot twist. You say that you can run Python from Atom, which means that Atom can use python, but Terminal can’t use pip? That’s strange and unusual, because both pip and python should be in the same place and Atom and Terminal should have equal access to them. What’s noteworthy here is step 9 in the Pygame instructions, which tells you to use pip3, which suggests that the Homebrew Python 3 package might install its pip at pip3.

I think you should download a package for executing shell commands inside Atom. I prefer process-palette, but if you want a live terminal, termination and atom-terminal-tab are both good. Once you have one of those, you can run python --version as a test.

I suspect that there are some things I need to know that you haven’t told me because you don’t understand their importance.


#7

I downloaded the atom-terminal-tab file, but couldn’t make any sense of how to install/run it.

Guess I’m just too much of a newbie for this.

Thanks anyway for your kind help.


#8

Don’t give up. How do you expect to learn anything and become less of a newbie if you give up?

What file are you talking about? You are meant to use Atom’s internal package install feature (Settings -> Install).


#9

I’m having the same problem. Atom can run python but not pygame. Pygame works perfectly on IDLE but Atom can’t seem to find it, just returns Module not found error. Any ideas?


#10

What OS are you on and what happens if you open a command line and use python --version?


#11

I’m on windows and I get python 3.6.4


#12

What package are you using to run Python?

In the command line, try to run pip install hg+http://bitbucket.org/pygame/pygame and tell me what happens. If that doesn’t work, try pip3 instead (and tell me which command worked).


#13

I tried both pip and pip3 and they both came up with-

Error [WinError 2] The system cannot find the file specified while executing command hg clone --noupdate -q http://bitbucket.org/pygame/pygame C:\Users\Olive\AppData\Local\Temp\pip-yvkxj0_6-build
Cannot find command ‘hg’


#14

Okay, you’re going to need to provide me with more information. If you’re not going off of the previously posted Pygame install instructions (which install Mercurial and the hg command), what are you using?

If you come into a thread and your situation differs from the situation presented by the original poster, you should always make sure to volunteer information that you know to be different (like how you’re on Windows).


#15

I don’t really understand your question but here is what I did to install pygame-
download off the website
change path to let python know location
terminal window- pip install pygame

I downloaded atom and tried placing pygame in the atom file but nothing would work. I hope this helps make more sense of the problem


#16

ok. I opened a terminal window, and found the python version is 2.7.10. And when I entered the command “pip3 install pygame”, response was "Requirement already satisfied: “pygame in /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages”

Where do I go from here?


#17

Also, my config.cson file in Atom shows

Runner:
python: “/usr/local/bin/python3”

Does this info help?


#18

So Pygame is installed in Python 3, and atom-runner is pointing at Python 3, but Pygame still isn’t detected.

Try running the script through atom-terminal-tab with the python3 command and see if it works. Where to go is to step through every step of the process until something stops working.


#19

I am fairly new to atom so what exactly is atom-terminal-tab. Do you have to install the package term because when I tried that it came up with errors messages. The instructions say I need to put $ apm install term but I am not sure where to put this. Does anyone know?


#20

It’s a terminal in Atom. @beeo was using it to test command-line instructions. Please read this thread from the beginning, including my discussion of packages that can be used to execute commands. You should select the one that best suits the way you wish to interact with your editor and with Python. I strongly endorse process-palette for its ability to automate tasks and then present them as commands in Atom that can be given keybindings or toolbar buttons.

Do you have to install the package term because when I tried that it came up with errors messages. The instructions say I need to put $ apm install term but I am not sure where to put this.

What instructions?