Install BS4.4.1 on Mac OSX

994 views
Skip to first unread message

jdoe2...@gmail.com

unread,
Jul 4, 2016, 10:39:12 PM7/4/16
to beautifulsoup, m_fos...@me.com
Hi all,

I am new to python and BS4.4.1.  I am trying to load BS4.4.1 and am following directions from Hello! Python.  When I type in sudo python setup.py install I get an error as shown below.

Traceback (most recent call last):
  File "setup.py", line 1, in <module>
    from setuptools import (
ImportError: No module named setuptools

Any suggestions on how to get around this would be greatly appreciated.  Is there something I need to load prior to this to get this to work?

Thanks,
Mitch

Jonathan Morgan

unread,
Jul 16, 2016, 6:40:22 PM7/16/16
to beautifulsoup, m_fos...@me.com
On OS X and Windows, for people new to Python, I usually recommend installing Anaconda: https://www.continuum.io/downloads

Anaconda gives you a Python environment that is local to your user account (I usually install it so it is just local to my user - you can also install it so it becomes the default python system wide), so you don't mess with the system's Python, and it is easy to set up and get working.  It also has something similar to VirtualEnvs (or you can just use virtualenv and virtualenvwrapper).

It is a scientific computing distribution, so it come with more than you need to just play with BeautifulSoup (it comes with numpy, scipy and pandas pre-compiled, for example), but it is the easiest way I've found for people new to Python and not on linux to get going with Python.  It even lets you upgrade python independent of the OS version through anaconda using conda, so you aren't tied to the version of Python currently provided by Apple.

If you install Anaconda, you'd then just run either:

conda install beautifulsoup4

OR

pip install beautifulsoup4

(it supports using pip in addition to conda).

Not an answer to your question, but a potential alternative to trying to get BeautifulSoup running in the system python in OS X.

- Jonathan Morgan

c...@zip.com.au

unread,
Jul 16, 2016, 7:09:39 PM7/16/16
to beauti...@googlegroups.com, m_fos...@me.com
On 04Jul2016 19:23, jdoe2...@gmail.com <jdoe2...@gmail.com> wrote:
>I am new to python and BS4.4.1. I am trying to load BS4.4.1 and am
>following directions from Hello! Python. When I type in *sudo python
>setup.py install *I get an error as shown below.
>
>Traceback (most recent call last):
> File "setup.py", line 1, in <module>
> from setuptools import (
>ImportError: No module named setuptools
>
>Any suggestions on how to get around this would be greatly appreciated. Is
>there something I need to load prior to this to get this to work?

I strongly suggest you don't do it this way.

Using sudo and the default python install places the module in the system
python area. On almost all platforms this is a mistake: it may interfere with
the OS supplied modules, and may in turn be damaged when OS supplied packagaes
are installed.

Instead, avoid sudo entirely and either:

install the module with --user, which installs in your home directory
Yes, this still needs setuptools - not directly solving your problem
here, just describing a better install process.

or

make a virtualenv (again, in your home directory) and install in it

Python3 ships with pip and virtualenv. I strongly recommend starting with
Python 3 anyway if you're new to Python. The OS Python is python 2.

So:
install python 3
install BS4 in your home directory
avoid sudo and interference in the system python libraries

Cheers,
Cameron Simpson <c...@zip.com.au>
Reply all
Reply to author
Forward
0 new messages