没有名为'bs4'的模块错误(No module named 'bs4' Error)
我打算做网络抓取,但我似乎陷入了第一步。
import urllib.request from bs4 import beautifulSoup wiki = "https://en.wikipedia.org/wiki/List_of_state_and_union_territory_capitals_in_India" page = urllib.urlopen(wiki) soup = BeautifulSoup(page) print(soup.prettify())
我写这些行只是为了测试,但它显示了一个错误
Traceback (most recent call last): File "C:/python programs/Web Scraping/wiki.py", line 3, in <module> from bs4 import beautifulSoup ModuleNotFoundError: No module named 'bs4' Process finished with exit code 1
我试图清除它的事情。
1)pip install beautifulsoup4(尝试使用easy_install)
2)检查环境变量中的python路径。 我在路径中包含了C:\ python和C:\ python \ Scripts。
3)尝试从crummy.com下载Beautiful Soup,然后从`python setup.py install命令安装。
我花了将近一整天的时间来清理它,尝试了几乎所有的解决方案,现在它确实令人沮丧。 但如果有人仍想将其标记为重复,您可以自由地进行复制。
有什么我错过了吗?
I planned to do web scraping, but I seem to be stuck on very first step.
import urllib.request from bs4 import beautifulSoup wiki = "https://en.wikipedia.org/wiki/List_of_state_and_union_territory_capitals_in_India" page = urllib.urlopen(wiki) soup = BeautifulSoup(page) print(soup.prettify())
I wrote these line just to test, but it shows an error that
Traceback (most recent call last): File "C:/python programs/Web Scraping/wiki.py", line 3, in <module> from bs4 import beautifulSoup ModuleNotFoundError: No module named 'bs4' Process finished with exit code 1
Things which i tried to clear it.
1) pip install beautifulsoup4 (tried this with easy_install as well)
2) check the python path in environment variable. i have included both C:\python and C:\python\Scripts in paths.
3) Tried downloading Beautiful Soup from crummy.com and then install from `python setup.py install command.
I spent almost whole day clearing this out, tried almost every solution and its literally frustrating now. but if anyone still wants to mark it as duplicate you are free to do so.
is there anything i have missed ?
原文:https://stackoverflow.com/questions/48509147
最满意答案
那这个呢:
<% link_to @post.title, post_path if post_path %>
What about this:
<% link_to @post.title, post_path if post_path %>
相关问答
更多-
下列中不属于面向对象的编程语言的是?[2022-05-30]
a -
如果要使用Ruby on Rails查找是否存在具有给定名称和密码的用户,则可以执行以下操作: User.where(user_name: params[:user_name], password: params[:password]).exists? 请参阅RailsGuides:对象的存在 。 原因问题的原因? 这就是原始海报最初提交的代码: User.find_by("user_name = ? AND password = ?", "#{params[:user_name]}", "#{param ...
-
我知道这与你想要的相反,但是你可以这样做: Rails.application.routes.recognize_path('/posts') 哪个会返回这样的哈希: {:controller=>"posts", :action=>"index"} 但我不知道有一个API给它哈希并返回路径。 您可以查看ActionDispatch :: Routing :: RouteSet API。 另外,请注意Rails.application.routes.routes返回一个Journey :: Routes对象数 ...
-
ember / rails - 包含下划线的rails路由中的奇怪行为(ember/rails - Strange behavior in rails route containing an underscore)[2022-03-01]
我做了一些挖掘,似乎有一个路由格式的配置。 尝试这个 # config/initializers/jsonapi.rb JSONAPI.configure do |config| config.route_format = :underscored_route end 这应该将路线变成“/ publishing_houses”而不是“出版社”,这将使它们与您正在使用的其他库兼容。 I did some digging and there appears to be a config for the r ... -
我发现了这个问题。 我需要使用可选的通配符: get 'path/to/ember-root/(*ember-stuff-ignored-by-rails)', to: 'your_controller#your_aciton' I found the question. I need to use an optional wildcard: get 'path/to/ember-root/(*ember-stuff-ignored-by-rails)', to: 'your_controller#you ...
-
没有路线匹配[POST]“/ projects / 70 / project_questions / new” 您已定义嵌套路由 ,因此它应该是这样的 <%= simple_form_for [@project, @project_question] do |f| %> No route matches [POST] "/projects/70/project_questions/new" You have nested routes defined,so it should be like this < ...
-
那这个呢: <% link_to @post.title, post_path if post_path %> What about this: <% link_to @post.title, post_path if post_path %>
-
从这里 : be_routable匹配器最好与should_not一起使用,以指定给定路由不应该是可路由的。 它可用于路由规范(在规范/路由中)和控制器规范(在规范/控制器中)。 在Capybara功能中你可以做到: scenario "could not register " do visit("/user/sign_up") expect(page.status_code).to be(404) end From here: The be_routable matcher is best us ...
-
你实际上可以断言这样的错误已被抛出,这对你来说是否足够? assert_raise ActionController::UrlGenerationError do patch :update, id: @reservation, reservation: { somefield: "data" } end You actually could assert an error like this has been thrown, would it be sufficient for you? asser ...
-
Parent.all( :include => :children, :conditions => "children.parent_id IS NULL") 我更喜欢使用此Railscasts剧集中显示的计数器缓存列,并在@PeterWong编写的父模型上获取:children_count Parent.all( :include => :children, :conditions => "children.parent_id IS NULL") I prefer to use counter cac ...