ImportError: No module named bs4 on mac

左心房为你撑大大i 提交于 2021-02-19 05:09:20

问题


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.


回答1:


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.



来源:https://stackoverflow.com/questions/15079941/importerror-no-module-named-bs4-on-mac

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!