###前提・実現したいこと
はじめまして、ここで初めて質問させていただきます
Pythonでサイトをスクレイピングしようと思っています
そこでBeautifulSoup4をインストールしてスクレイピングしようと思ったのですがいくらやってもエラーが出てしまいます
おそらくBeautifulSoupというモジュールはないという主旨のエラーだと思うのですがどうやったら解決しますか、プログラムも初心者なのでできたら分かりやすく教えていただけますか
スペック
Windows8.1
Python3.6.3
Pycharm
###発生している問題・エラーメッセージ
C:\Users\私のユーザー名\PycharmProjects\untitled1\venv\Scripts\python.exe C:/Users/私のユーザー名/PycharmProjects/untitled1/nikkei.py Traceback (most recent call last): File "C:/Users/私のユーザー名/PycharmProjects/untitled1/nikkei.py", line 3, in <module> import BeautifulSoup ModuleNotFoundError: No module named 'BeautifulSoup' Process finished with exit code 1
###該当のソースコード
#coding: UTF-8 import urllib import BeautifulSoup url = "https://www.nikkei.com/" html = urllib.urlopen(url) soup = BeautifulSoup(html, "html.parser") title_tag = soup.span print (title_tag)
###試したこと
BeautifulSorpのとこだけ波線が出ていたので認識してないと思いました
importの前にfrom bs4をつけていましたが同じエラーが出ました
from bs4 import BeautifulSoup
BeautifulSoupの他にBeautifulSoup4、beautifulsorp、beautifulsorp4と入力してみましたがまた同じエラーが出ました
インストールしたときにコマンドプロンプトでpipでインストールしようとしたんですが
C:\Users\私のユーザー名>pip install beautifulsoup4 Collecting beautifulsoup4 Using cached beautifulsoup4-4.6.0-py3-none-any.whl Installing collected packages: beautifulsoup4 Exception: Traceback (most recent call last): File "c:\program files\python36\lib\site-packages\pip\basecommand.py", line 21 5, in main status = self.run(options, args) File "c:\program files\python36\lib\site-packages\pip\commands\install.py", li ne 342, in run prefix=options.prefix_path, File "c:\program files\python36\lib\site-packages\pip\req\req_set.py", line 78 4, in install **kwargs File "c:\program files\python36\lib\site-packages\pip\req\req_install.py", lin e 851, in install self.move_wheel_files(self.source_dir, root=root, prefix=prefix) File "c:\program files\python36\lib\site-packages\pip\req\req_install.py", lin e 1064, in move_wheel_files isolated=self.isolated, File "c:\program files\python36\lib\site-packages\pip\wheel.py", line 345, in move_wheel_files clobber(source, lib_dir, True) File "c:\program files\python36\lib\site-packages\pip\wheel.py", line 316, in clobber ensure_dir(destdir) File "c:\program files\python36\lib\site-packages\pip\utils\__init__.py", line 83, in ensure_dir os.makedirs(path) File "c:\program files\python36\lib\os.py", line 220, in makedirs mkdir(name, mode) PermissionError: [WinError 5] アクセスが拒否されました。: 'c:\program files\py thon36\Lib\site-packages\beautifulsoup4-4.6.0.dist-info'
と出ていたので管理者権限でコマンドプロンプトを開き同じくインストールしたらそのときはインストールできました
C:\WINDOWS\system32>pip install beautifulsoup4 Collecting beautifulsoup4 Using cached beautifulsoup4-4.6.0-py3-none-any.whl Installing collected packages: beautifulsoup4 Successfully installed beautifulsoup4-4.6.0
C:\WINDOWS\system32>pip list DEPRECATION: The default format will switch to columns in the future. You can us e --format=(legacy|columns) (or define a format=(legacy|columns) in your pip.con f under the [list] section) to disable this warning. asn1crypto (0.23.0) beautifulsoup4 (4.6.0) cffi (1.11.2) cryptography (2.1.3) idna (2.6) pip (9.0.1) pycparser (2.18) pyOpenSSL (17.4.0) setuptools (28.8.0) six (1.11.0)
管理者権限でインストールしたことをおもいだしたので
Program filesのアクセス権をフルコントロールしてみましたが同じ結果になりました
もう一度再インストールしてみましたが管理者権限のコマンドプロンプトでしか受付せず結果同じエラーになってしまいます

回答3件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2017/11/30 00:31
2017/11/30 01:30
2017/11/30 01:36