Adding modules in atom in python





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}







0















I have the module pygame and tkinter installed on my computer, but I cannot find out how to access them in the text editor atom. I can use them in IDLE by using



import pygame 


but when I try to import it in atom it doesn't recognize the module. Anybody know why? All of my other imports work by the way (time, random, etc.) but I think that they work because they come installed with python (right?).










share|improve this question























  • Probably something to do with your system path variables. Try running python -c "import sys; print(sys.path);" and make sure the directories with your modules are there.

    – Tomothy32
    Nov 24 '18 at 7:59











  • This is what it said. I have no idea what this means. (By the way I added a 3 after python because I use python 3). ['', '/Library/Frameworks/Python.framework/Versions/3.7/lib/python37.zip', '/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7', '/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/lib-dynload', '/Users/bstanley2022/Library/Python/3.7/lib/python/site-packages', '/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages']

    – B S
    Nov 24 '18 at 20:21




















0















I have the module pygame and tkinter installed on my computer, but I cannot find out how to access them in the text editor atom. I can use them in IDLE by using



import pygame 


but when I try to import it in atom it doesn't recognize the module. Anybody know why? All of my other imports work by the way (time, random, etc.) but I think that they work because they come installed with python (right?).










share|improve this question























  • Probably something to do with your system path variables. Try running python -c "import sys; print(sys.path);" and make sure the directories with your modules are there.

    – Tomothy32
    Nov 24 '18 at 7:59











  • This is what it said. I have no idea what this means. (By the way I added a 3 after python because I use python 3). ['', '/Library/Frameworks/Python.framework/Versions/3.7/lib/python37.zip', '/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7', '/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/lib-dynload', '/Users/bstanley2022/Library/Python/3.7/lib/python/site-packages', '/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages']

    – B S
    Nov 24 '18 at 20:21
















0












0








0








I have the module pygame and tkinter installed on my computer, but I cannot find out how to access them in the text editor atom. I can use them in IDLE by using



import pygame 


but when I try to import it in atom it doesn't recognize the module. Anybody know why? All of my other imports work by the way (time, random, etc.) but I think that they work because they come installed with python (right?).










share|improve this question














I have the module pygame and tkinter installed on my computer, but I cannot find out how to access them in the text editor atom. I can use them in IDLE by using



import pygame 


but when I try to import it in atom it doesn't recognize the module. Anybody know why? All of my other imports work by the way (time, random, etc.) but I think that they work because they come installed with python (right?).







python module atom-editor






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 24 '18 at 7:01









B SB S

254




254













  • Probably something to do with your system path variables. Try running python -c "import sys; print(sys.path);" and make sure the directories with your modules are there.

    – Tomothy32
    Nov 24 '18 at 7:59











  • This is what it said. I have no idea what this means. (By the way I added a 3 after python because I use python 3). ['', '/Library/Frameworks/Python.framework/Versions/3.7/lib/python37.zip', '/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7', '/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/lib-dynload', '/Users/bstanley2022/Library/Python/3.7/lib/python/site-packages', '/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages']

    – B S
    Nov 24 '18 at 20:21





















  • Probably something to do with your system path variables. Try running python -c "import sys; print(sys.path);" and make sure the directories with your modules are there.

    – Tomothy32
    Nov 24 '18 at 7:59











  • This is what it said. I have no idea what this means. (By the way I added a 3 after python because I use python 3). ['', '/Library/Frameworks/Python.framework/Versions/3.7/lib/python37.zip', '/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7', '/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/lib-dynload', '/Users/bstanley2022/Library/Python/3.7/lib/python/site-packages', '/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages']

    – B S
    Nov 24 '18 at 20:21



















Probably something to do with your system path variables. Try running python -c "import sys; print(sys.path);" and make sure the directories with your modules are there.

– Tomothy32
Nov 24 '18 at 7:59





Probably something to do with your system path variables. Try running python -c "import sys; print(sys.path);" and make sure the directories with your modules are there.

– Tomothy32
Nov 24 '18 at 7:59













This is what it said. I have no idea what this means. (By the way I added a 3 after python because I use python 3). ['', '/Library/Frameworks/Python.framework/Versions/3.7/lib/python37.zip', '/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7', '/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/lib-dynload', '/Users/bstanley2022/Library/Python/3.7/lib/python/site-packages', '/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages']

– B S
Nov 24 '18 at 20:21







This is what it said. I have no idea what this means. (By the way I added a 3 after python because I use python 3). ['', '/Library/Frameworks/Python.framework/Versions/3.7/lib/python37.zip', '/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7', '/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/lib-dynload', '/Users/bstanley2022/Library/Python/3.7/lib/python/site-packages', '/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages']

– B S
Nov 24 '18 at 20:21














1 Answer
1






active

oldest

votes


















0














Firstly, atom is a text editor, it does not run python code by itself. So when you say you're trying to "import it in atom", I have to assume you're using an atom plugin that can interpret code. One common plugin for this is "script".



You need to head to the atom settings to check which python install is being used. Do this by first entering atom settings with control+,, then click on "packages" on the navagator, and click on "script" (or whatever plugin you're using to run your code, e.g. script, Hydrogen, atom-runner etc.). In the script settings, click on "view code", which will open the source code of script. On the tree nagivator on the left, navigate to script-->lib-->grammars-->python.coffee



In this coffeescript file, you should find the python interpreter that atom-script is using. For example, since I use anaconda, mine reads:



exports.Python =
'Selection Based':
command: '/home/username/.miniconda3/envs/local35/bin/python'
args: (context) -> ['-u', '-c', context.getCode()]


If you run linux or mac, now you can open a terminal and run



which python


import pygame should theoretically work if the system python matches the one atom is using, so these will probably be different. Just replace the python path in the coffeescript file with the result of which python. If these are already the same, this process should at least give you some clues to further diagnose the issue.



Personally, I recommend the use of Anaconda to keep track of your python environments and modules, it can really help with issues like this.



Also do make sure that python -c "import pygame" works, because if it doesn't, this isn't an atom issue at all.






share|improve this answer
























  • I got this error when using python -c "import pygame". What issue is this then? I think it has something to do with the paths, because it work in idle fine. Here's the error bstanley2022-mac:grammars bstanley2022$ python -c "import pygame" Traceback (most recent call last): File "<string>", line 1, in <module> ImportError: No module named pygame

    – B S
    Nov 25 '18 at 23:15













  • This question has been framed incorrectly in that case; it has nothing to do with Atom. That's quite a basic python error, it just means python can't see the module. I can't tell you the fix without more info, but spend some time reading similar questions and I'm sure you'll figure it out. If not, ask a new question, but compile more info on the problem first.

    – John Kealy
    Nov 26 '18 at 10:20












Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53455945%2fadding-modules-in-atom-in-python%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









0














Firstly, atom is a text editor, it does not run python code by itself. So when you say you're trying to "import it in atom", I have to assume you're using an atom plugin that can interpret code. One common plugin for this is "script".



You need to head to the atom settings to check which python install is being used. Do this by first entering atom settings with control+,, then click on "packages" on the navagator, and click on "script" (or whatever plugin you're using to run your code, e.g. script, Hydrogen, atom-runner etc.). In the script settings, click on "view code", which will open the source code of script. On the tree nagivator on the left, navigate to script-->lib-->grammars-->python.coffee



In this coffeescript file, you should find the python interpreter that atom-script is using. For example, since I use anaconda, mine reads:



exports.Python =
'Selection Based':
command: '/home/username/.miniconda3/envs/local35/bin/python'
args: (context) -> ['-u', '-c', context.getCode()]


If you run linux or mac, now you can open a terminal and run



which python


import pygame should theoretically work if the system python matches the one atom is using, so these will probably be different. Just replace the python path in the coffeescript file with the result of which python. If these are already the same, this process should at least give you some clues to further diagnose the issue.



Personally, I recommend the use of Anaconda to keep track of your python environments and modules, it can really help with issues like this.



Also do make sure that python -c "import pygame" works, because if it doesn't, this isn't an atom issue at all.






share|improve this answer
























  • I got this error when using python -c "import pygame". What issue is this then? I think it has something to do with the paths, because it work in idle fine. Here's the error bstanley2022-mac:grammars bstanley2022$ python -c "import pygame" Traceback (most recent call last): File "<string>", line 1, in <module> ImportError: No module named pygame

    – B S
    Nov 25 '18 at 23:15













  • This question has been framed incorrectly in that case; it has nothing to do with Atom. That's quite a basic python error, it just means python can't see the module. I can't tell you the fix without more info, but spend some time reading similar questions and I'm sure you'll figure it out. If not, ask a new question, but compile more info on the problem first.

    – John Kealy
    Nov 26 '18 at 10:20
















0














Firstly, atom is a text editor, it does not run python code by itself. So when you say you're trying to "import it in atom", I have to assume you're using an atom plugin that can interpret code. One common plugin for this is "script".



You need to head to the atom settings to check which python install is being used. Do this by first entering atom settings with control+,, then click on "packages" on the navagator, and click on "script" (or whatever plugin you're using to run your code, e.g. script, Hydrogen, atom-runner etc.). In the script settings, click on "view code", which will open the source code of script. On the tree nagivator on the left, navigate to script-->lib-->grammars-->python.coffee



In this coffeescript file, you should find the python interpreter that atom-script is using. For example, since I use anaconda, mine reads:



exports.Python =
'Selection Based':
command: '/home/username/.miniconda3/envs/local35/bin/python'
args: (context) -> ['-u', '-c', context.getCode()]


If you run linux or mac, now you can open a terminal and run



which python


import pygame should theoretically work if the system python matches the one atom is using, so these will probably be different. Just replace the python path in the coffeescript file with the result of which python. If these are already the same, this process should at least give you some clues to further diagnose the issue.



Personally, I recommend the use of Anaconda to keep track of your python environments and modules, it can really help with issues like this.



Also do make sure that python -c "import pygame" works, because if it doesn't, this isn't an atom issue at all.






share|improve this answer
























  • I got this error when using python -c "import pygame". What issue is this then? I think it has something to do with the paths, because it work in idle fine. Here's the error bstanley2022-mac:grammars bstanley2022$ python -c "import pygame" Traceback (most recent call last): File "<string>", line 1, in <module> ImportError: No module named pygame

    – B S
    Nov 25 '18 at 23:15













  • This question has been framed incorrectly in that case; it has nothing to do with Atom. That's quite a basic python error, it just means python can't see the module. I can't tell you the fix without more info, but spend some time reading similar questions and I'm sure you'll figure it out. If not, ask a new question, but compile more info on the problem first.

    – John Kealy
    Nov 26 '18 at 10:20














0












0








0







Firstly, atom is a text editor, it does not run python code by itself. So when you say you're trying to "import it in atom", I have to assume you're using an atom plugin that can interpret code. One common plugin for this is "script".



You need to head to the atom settings to check which python install is being used. Do this by first entering atom settings with control+,, then click on "packages" on the navagator, and click on "script" (or whatever plugin you're using to run your code, e.g. script, Hydrogen, atom-runner etc.). In the script settings, click on "view code", which will open the source code of script. On the tree nagivator on the left, navigate to script-->lib-->grammars-->python.coffee



In this coffeescript file, you should find the python interpreter that atom-script is using. For example, since I use anaconda, mine reads:



exports.Python =
'Selection Based':
command: '/home/username/.miniconda3/envs/local35/bin/python'
args: (context) -> ['-u', '-c', context.getCode()]


If you run linux or mac, now you can open a terminal and run



which python


import pygame should theoretically work if the system python matches the one atom is using, so these will probably be different. Just replace the python path in the coffeescript file with the result of which python. If these are already the same, this process should at least give you some clues to further diagnose the issue.



Personally, I recommend the use of Anaconda to keep track of your python environments and modules, it can really help with issues like this.



Also do make sure that python -c "import pygame" works, because if it doesn't, this isn't an atom issue at all.






share|improve this answer













Firstly, atom is a text editor, it does not run python code by itself. So when you say you're trying to "import it in atom", I have to assume you're using an atom plugin that can interpret code. One common plugin for this is "script".



You need to head to the atom settings to check which python install is being used. Do this by first entering atom settings with control+,, then click on "packages" on the navagator, and click on "script" (or whatever plugin you're using to run your code, e.g. script, Hydrogen, atom-runner etc.). In the script settings, click on "view code", which will open the source code of script. On the tree nagivator on the left, navigate to script-->lib-->grammars-->python.coffee



In this coffeescript file, you should find the python interpreter that atom-script is using. For example, since I use anaconda, mine reads:



exports.Python =
'Selection Based':
command: '/home/username/.miniconda3/envs/local35/bin/python'
args: (context) -> ['-u', '-c', context.getCode()]


If you run linux or mac, now you can open a terminal and run



which python


import pygame should theoretically work if the system python matches the one atom is using, so these will probably be different. Just replace the python path in the coffeescript file with the result of which python. If these are already the same, this process should at least give you some clues to further diagnose the issue.



Personally, I recommend the use of Anaconda to keep track of your python environments and modules, it can really help with issues like this.



Also do make sure that python -c "import pygame" works, because if it doesn't, this isn't an atom issue at all.







share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 25 '18 at 17:28









John KealyJohn Kealy

809




809













  • I got this error when using python -c "import pygame". What issue is this then? I think it has something to do with the paths, because it work in idle fine. Here's the error bstanley2022-mac:grammars bstanley2022$ python -c "import pygame" Traceback (most recent call last): File "<string>", line 1, in <module> ImportError: No module named pygame

    – B S
    Nov 25 '18 at 23:15













  • This question has been framed incorrectly in that case; it has nothing to do with Atom. That's quite a basic python error, it just means python can't see the module. I can't tell you the fix without more info, but spend some time reading similar questions and I'm sure you'll figure it out. If not, ask a new question, but compile more info on the problem first.

    – John Kealy
    Nov 26 '18 at 10:20



















  • I got this error when using python -c "import pygame". What issue is this then? I think it has something to do with the paths, because it work in idle fine. Here's the error bstanley2022-mac:grammars bstanley2022$ python -c "import pygame" Traceback (most recent call last): File "<string>", line 1, in <module> ImportError: No module named pygame

    – B S
    Nov 25 '18 at 23:15













  • This question has been framed incorrectly in that case; it has nothing to do with Atom. That's quite a basic python error, it just means python can't see the module. I can't tell you the fix without more info, but spend some time reading similar questions and I'm sure you'll figure it out. If not, ask a new question, but compile more info on the problem first.

    – John Kealy
    Nov 26 '18 at 10:20

















I got this error when using python -c "import pygame". What issue is this then? I think it has something to do with the paths, because it work in idle fine. Here's the error bstanley2022-mac:grammars bstanley2022$ python -c "import pygame" Traceback (most recent call last): File "<string>", line 1, in <module> ImportError: No module named pygame

– B S
Nov 25 '18 at 23:15







I got this error when using python -c "import pygame". What issue is this then? I think it has something to do with the paths, because it work in idle fine. Here's the error bstanley2022-mac:grammars bstanley2022$ python -c "import pygame" Traceback (most recent call last): File "<string>", line 1, in <module> ImportError: No module named pygame

– B S
Nov 25 '18 at 23:15















This question has been framed incorrectly in that case; it has nothing to do with Atom. That's quite a basic python error, it just means python can't see the module. I can't tell you the fix without more info, but spend some time reading similar questions and I'm sure you'll figure it out. If not, ask a new question, but compile more info on the problem first.

– John Kealy
Nov 26 '18 at 10:20





This question has been framed incorrectly in that case; it has nothing to do with Atom. That's quite a basic python error, it just means python can't see the module. I can't tell you the fix without more info, but spend some time reading similar questions and I'm sure you'll figure it out. If not, ask a new question, but compile more info on the problem first.

– John Kealy
Nov 26 '18 at 10:20




















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53455945%2fadding-modules-in-atom-in-python%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







這個網誌中的熱門文章

Xamarin.form Move up view when keyboard appear

Post-Redirect-Get with Spring WebFlux and Thymeleaf

Anylogic : not able to use stopDelay()