简体   繁体   English

Python BeautifulSoup Mac安装错误

[英]Python BeautifulSoup Mac Installation Error

I am completely new to all things programming. 我对编程万物完全陌生。 As I am working to learn the basics of Python, I have run into a problem that I've been unable to work through by reading and Googling. 在我学习Python基础知识的过程中,遇到了一个我无法通过阅读和Googling解决的问题。

I am trying to install BeautifulSoup, and I thought I had done so successfully, but when I try to test whether or not it's installed correctly I get an error. 我正在尝试安装BeautifulSoup,但我想我已经成功完成了,但是当我尝试测试它是否正确安装时,出现错误。

I am using PyCharm and typed the following into the Python Console: 我正在使用PyCharm,并在Python控制台中输入了以下内容:

>>> from bs4 import BeautifulSoup

And I receive the following error: 而且我收到以下错误:

Traceback (most recent call last):
  File "<input>", line 1, in <module>
  File "/Applications/PyCharm CE.app/Contents/helpers/pydev/_pydev_bundle/pydev_import_hook.py", line 21, in do_import
    module = self._system_import(name, *args, **kwargs)
ImportError: No module named 'bs4'

I read through a previous thread about a BeautifulSoup install error and one of the things that was mentioned was to check the preferences settings in PyCharm to ensure that it's using the right version of Python . 我通读了有关BeautifulSoup安装错误的上一个线程,提到的一件事是检查PyCharm中的首选项设置,以确保它使用的Python版本正确。 . .

PyCharm项目口译员截图

Anyway, I can't seem to figure out what's wrong, so any insight and help in resolving this issue would be tremendously appreciated. 无论如何,我似乎无法弄清楚出了什么问题,因此,对于解决此问题的任何见解和帮助,将深表感谢。

You can use pip to install beautifulsoup on mac, by typing in the following command in Terminal: 通过在终端中输入以下命令,可以使用pip在Mac上安装beautifulsoup:

pip install beautifulsoup4

You might be facing some permission problems if you are running the OS X preinstalled python as interpreter. 如果您正在运行OS X预装的python作为解释器,则可能会遇到一些权限问题。 I would suggest installing python with Homebrew if that's the case. 如果是这种情况,我建议使用Homebrew安装python。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM