0

Atom: 1.39.1

I am getting the below error while running python code from Atom editor.

ModuleNotFoundError: No module named 'foo'

The same code works fine from pycharm.

Note: Due to security reasons, I can't put the entire code here for reference.

I have added all the necessary paths in sys.path & environment variables but not sure why atom alone couldn't recognize python files. Any assistance?

5
  • are you using the same python interpreter in pycharm and in Atom? Pycharm automatically creates venv for new project, I am not familiar with Atom but that could part of the cause of this issue. Aug 5, 2019 at 13:39
  • @griffin_cosgrove I am not sure where to check and update the changes in ATOM if that would be the real reason for the cause.
    – Learner
    Aug 5, 2019 at 13:46
  • 1
    in Pycharm it is in the bottom left corner click python console and it should say what version of python Pycharm is using for that project, additionally right next to that click terminal and take note if you are using a venv in Pycharm. Myself not familiar with ATOM i would suggest looking at the docs for atom at atom.io/docs Aug 5, 2019 at 13:53
  • "I am getting the below error while running python code from Atom editor" - I assume you are trying to run python from atom itself. Are you using a package? If so, which one?
    – abhivemp
    Aug 5, 2019 at 19:20
  • @abhivemp I am using 'Script and autocomplete-python' package to run python from atom.
    – Learner
    Aug 6, 2019 at 14:28

2 Answers 2

1

autocomplete python does have some issues. I recommend you use atom python run.

  1. Install the package in atom. Then do the following.

  2. Make sure python is installed on your computer and it's added to your PATH.

  3. Restart atom

  4. To run your (.py) file, hit F5 or F6

If you just want to run python3 through atom: Open the atom-python-run package settings (atom Settings >> packages >> find atom-python-run >> settings)

In the F5 command section, change the default to python3 {file}. It should look something like this.

Make sure that F5 doesn't interfere with another command from another package. Or else you can use F6 as well.

You should be good to go!

Hope this helps!

0

I think the reason why this is not working is because there is no folder called venv. In pycharm it has the folder but in atom there is no folder like that. But I don't know to install the venv thing.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.