user2020088
user2020088

Reputation: 51

Python, Install Beautiful Soup4-4.1.3 on Mac. Access Denied?

I can't figure out how to install BeautifulSoup4 on Python. I've downloaded it, unpacked it and moved it to User directory. Typed in Terminal 'cd beautifulsoup4-4.1.3' to enter directory Then I type 'python setup.py install' Then I get this message:

    Adams-iMac:beautifulsoup4-4.1.3 adamparis$ python setup.py install
running install
running build
running build_py
creating build
creating build/lib
creating build/lib/bs4
copying bs4/__init__.py -> build/lib/bs4
copying bs4/dammit.py -> build/lib/bs4
copying bs4/element.py -> build/lib/bs4
copying bs4/testing.py -> build/lib/bs4
creating build/lib/bs4/builder
copying bs4/builder/__init__.py -> build/lib/bs4/builder
copying bs4/builder/_html5lib.py -> build/lib/bs4/builder
copying bs4/builder/_htmlparser.py -> build/lib/bs4/builder
copying bs4/builder/_lxml.py -> build/lib/bs4/builder
creating build/lib/bs4/tests
copying bs4/tests/__init__.py -> build/lib/bs4/tests
copying bs4/tests/test_builder_registry.py -> build/lib/bs4/tests
copying bs4/tests/test_docs.py -> build/lib/bs4/tests
copying bs4/tests/test_html5lib.py -> build/lib/bs4/tests
copying bs4/tests/test_htmlparser.py -> build/lib/bs4/tests
copying bs4/tests/test_lxml.py -> build/lib/bs4/tests
copying bs4/tests/test_soup.py -> build/lib/bs4/tests
copying bs4/tests/test_tree.py -> build/lib/bs4/tests
running install_lib
creating /Library/Python/2.7/site-packages/bs4
error: could not create '/Library/Python/2.7/site-packages/bs4': Permission denied
Adams-iMac:beautifulsoup4-4.1.3 adamparis$ 

At the end it says 'Permission denied. Why is this?

Upvotes: 0

Views: 3233

Answers (3)

user2125828
user2125828

Reputation: 21

you can type sudo pip install beautifulsoup4

Upvotes: 2

andrewdotn
andrewdotn

Reputation: 34873

It’s trying to install into the system directory /Library/Python, but only the root user can do that. You could use sudo to become root, but—

If you just want to install the package for yourself, try python setup.py install --user to install into your home directory under /Users/yourname/Library/Python/2.7/lib/python/site-packages. It’s automatically in your Python path, you won’t need root access, and in the extremely remote event that there is malware in the Python package you downloaded, it will corrupt only your account instead of the entire computer.

pip also has a --user option for installing directly from PyPi, as do some versions of easy_install, but not all of them… Python packaging can be messy sometimes.

Upvotes: 1

alexhb
alexhb

Reputation: 445

try $ sudo python setup.py install. type in your password when prompted.

Upvotes: 4

Related Questions