0

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?

2
  • sudo? are you logged as root? May 6, 2013 at 0:13
  • Thanks for your reply. I did use Sudo and it worked. Many thanks. May 7, 2013 at 10:24

3 Answers 3

4

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

0
2

you can type sudo pip install beautifulsoup4

1

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.

1
  • I worked first from the 1st answer and that worked. Thanks for your reply. May 7, 2013 at 10:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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