3

I sat down tonight and have decided to leran how to use python. Inspired by this webpage scraping article. cam.ly/danesblog/2011/01/craigslist-arbitrage/

after working through a tutorial I:

1) downloaded and installed python: http://www.python.org/getit/ first 3.3 then 2.7

2) downloaded bs4: www.crummy.com/software/BeautifulSoup/bs4/download/

3) followed Brian Clapper's instructions: How can I install the Beautiful Soup module on the Mac?

  • tried both easy_install and python setup.py install methods

I am still getting "ImportError: No module named bs4"

Python is installed in applications folder, the bs4 package auto installs in Library Is this the problem? I tried copying and moving the folder into Python application, but didn't work.

I have also tried both forms:

  • from BeautifulSoup import BeautifulSoup
  • from bs4 import BeautifulSoup

Thank you for the support.

Community
  • 1
  • 1
jjr4826
  • 194
  • 3
  • 12
  • BeautifulSoup is Python code in its entirety. Put the directory in your `site-packages` directory or somewhere else on your Python path and be done with it. – mechanical_meat Feb 26 '13 at 01:54
  • Are you sure you're using the correct version of Python (or easy_install) - eg: make sure you're attempting to run the Python that you've used to install the package – Jon Clements Feb 26 '13 at 02:04
  • Yes, if you installed python.org Pythons, you'll also need to install versions of `easy_install` for each of them. Otherwise, you are likely using the Apple-supplied `easy_install` commands which will install to the system Pythons instead. See https://pypi.python.org/pypi/distribute#installation-instructions – Ned Deily Feb 26 '13 at 02:23
  • 1
    I found site-packages with help from http://stackoverflow.com/questions/122327/how-do-i-find-the-location-of-my-python-site-packages-directory, and just copied the installed bs4 files in there. I had to change, back to python 2.7 because even though I was downloading beautifulsoup 4-4.1.3 one of the files still had python 2 format of "print." Thanks for pointing me in the right direction. I know considerably more now than I did 48 hours ago – jjr4826 Feb 27 '13 at 14:34

1 Answers1

-2

The solution is in setting up the PATH the packages get installed. EPD or Canopy create their VirtualEnv set up in the .\~profile and .\~bash_profile files. These path may not be identical to the path pip install or easy_install try to install the packages. If you open bash_profile or profile files there should be a path similar to this :

VIRTUAL_ENV_DISABLE_PROMPT=1 source /Users/test_user/Library/Enthought/Canopy_64bit/User/bin/activate 

I am using Enthought as my python editor so yours will be something else but what is important is if you are using pip or easy_install the address the python packages are installed should point here. Or put another way, your active virtual environment set up is in this address.

Kohlbrr
  • 3,861
  • 1
  • 21
  • 24