(Python) How to install BeautifulSoup in atom on Mac?


#1

Hey atomists

It’s my first day with atom which I find is great!

But, one thing that bugs me is a package installation problem.

“from bs4 import BeautifulSoup” doesn’t work and I cannot find a way to install BeautifulSoup.


#2

What version of Python are you using and are you able to import BeautifulSoup when you use python script.py from the Terminal?


#3

Thanks for asking. It is 3.6.2 and yes I could import BeautifulSoup from python3 script.py.


#4

But what about python script.py? If you have to use python3 as your command, that suggests that your computer is set up so that Python 2 is the primary. In that case, if the Atom package you’re using is using python, then it’s using the wrong one.


#5

What a great inference! Then how can I change the link to 3.6?

      1. 오후 12:44에 “Damned Scholar” github_atom@discoursemail.com님이
        작성:

#6

See if this helps ->
http://bfy.tw/EVpo


#7

You have two choices. Either point the package at python3 (I can tell you how, but first you have to tell me which one you’re using) or you can use pyenv. If you haven’t used pyenv before, it’s worth learning how it works.


#8

I was hoping to give you a break so you can get some sleep… or is your turn at nightshift?


#9

I’m a night owl.


#11

Thank you folks!

Here are what I have done to solve the following problem at Atom.

from bs4 import BeautifulSoup
ImportError: No module named bs4

  1. At the menu, Atom > Config
  • I added the following at the end of config file and then ran my bs4.py
    runner:
    scopes:
    python: “/Library/Frameworks/Python.framework/Versions/3.6/bin/python3”
  • But, didn’t work.
  1. At the menu, Packages > Script Configure
  • I added Python3 into the command box. (regardless of removing #1, the above one)
  • Yes, it worked! :slight_smile:
  1. Pyenv
  • As the first time user, I installed Pyenv and then reinstalled 3.6.3.
  • made 3.6.3 global by doing $ pyenv global 3.6.3
  • Nope. it didn’t work for the atom problem.
  1. Under Applications, Python 3.6 folder > Python Launcher > Preference
  • I changed the interpreter value to /usr/local/bin/python3
  • Failed again.

#12

Hello.

@DamnedScholar is better suited to help you. I would want to make something clear… what Atom uses in the program itself, has nothing to do with how you execute your script. Please make loose the Atom program and what Packages give you.

I leave you in good hands for further discussion when/if @DamnedScholar is available.

행운


#13

Try just

runner:
  scopes:
    python: "python3"

At the menu, Packages > Script Configure

Okay. Here it sounds like you’re using the script package, but #1 shows atom-runner's configuration. Are you trying out both packages?


#14

Thank you!


#15

Yes I tried both.

With the new atom-runner config, I still got “ImportError: No module named bs4”


#16

Here’s what I use: process-palette. It asks only for a little command line familiarity, and what it gives in return is a full suite of features for automating commands. I use it to run my scripts, since I find it more capable than most of the other packages.

Here’s an example of how I use it:


#17

process-palette works. Thank YOU so much :slight_smile:


#18

No problem. :slight_smile:


#19

Fly in the ointment (sorry)
How do you get past the case of…

name = input('What is your name?')

#20

I don’t. process-palette doesn’t handle that any better than the others, but I also don’t write scripts like that so I have no need for it. When I’m writing a Python script to automate something, it’s because I don’t want to have to interact with it. So if there are specific configuration details, I’ll have it read a JSON file or write them into the script. When I’m interacting with the code and experimenting with new things, I use a REPL, which is more flexible and responsive than the solutions within Atom.


#21

I wish I could understand those screenshots you just shared.
I found this page because I cannot use python3.6 and have Beautifulsoup work as well.
I can only use Python 2.7 for Beautiful to work… apparently.
Is python3.6 really necessary for my code to import requests and/or run BeautifulSoup?

Any help or insight on the matter will be greatly appreciated DamnedScholar. Cheers!