Python BS4 error: No module named html.entities - python

So I installed BS4 with PIP, but when I do
from bs4 import beautifulsoup4
I get this
ImportError: No module named html.entities
I've done all the research I can into this as it seems to be a fairly rare problem, and the only thing I could find is to only have one version of python installed, yet I need both python two and three installed so that wouldn't work.
So I was wondering if there's a better way to fix this error, I have read http://www.crummy.com/software/BeautifulSoup/bs4/doc/#problems-after-installation by the way, there appeared to be nothing in there that would help my situation.
Thanks for your help! And sorry for my formatting

Related

Python not able to import any module

I don't know whether I've just installed them wrong or there's another problem. I installed the ebay sdk but whenever I try to import it I get
ModuleNotFoundError: No module named 'ebaysdk'
Are there any common problems with this I could check for a solution? It shouldn't be the code as I copied it from the example code off the website.
Thanks for any help.
P.S I'm using 3.6

lxml not being recognized in bs4: Python 3 on mac

So, I have a mac on High Sierra and I am trying to import and use an api. This is api is a python3 api and uses bs4, and specifically is using lxml within bs4 in order to parse a webpage.
However, I am having an issue getting bs4 to recognize that I have lxml installed on my machine. I have installed both of them using pip, and both appear to have installed correctly. I can write a program with ‘import bs4’ and ‘import lxml’ at the top and it compiles and runs perfectly fine. However, no matter what I do I always get the following error when I run a program using this api.
bs4.FeatureNotFound: Couldn't find a tree builder with the features you requested: lxml. Do you need to install a parser library?
On top of this, when I run the following code
import lxml
import bs4
print(bs4.builder.builder_registry.builders)
the output is
[<class 'bs4.builder._htmlparser.HTMLParserTreeBuilder'>]
With no lxml listed.
I have tried everything I have found on the various stack overflow threads related to this. I have uninstalled and reinstalled both lxml and bs4 through various methods(pip, easy install, manually installing, homebrew). I've manually linked lxml from brew. And other things ive probably forgotten. However I cant get it to work.
Anyone have any ideas/has anyone gone through this before. Its possible I'm completely missing something small or stupid, since I've never messed with bs4 before, but I dont know.
I'm not exactly sure what's the cause, but I had a similar case with a Flask app I'm working on. I worked around it by importing bs4 locally in the function where I needed it.
One symptom I had was when I logged bs4.builder.builder_registry.builders at the top of my module, the logs ended up showing two entries: first with the proper builders and then with only HTML.

Sudden module imports issues

I've encountered one peculiar issue I just can't understand.
I've been working on a code in PyCharm, using Python 3.6 (Windows 10) and I've imported few modules for that objective like so:
import requests
from bs4 import BeautifulSoup
import time
import lxml
For few days now I've been coding having no problems, I've run my code several times to test it and everything been going well until suddenly, without changing anything in the interpreter or any other setting, the modules seem to generate a lot of import errors such as:
ImportError: cannot import name 'BeautifulSoup'
AttributeError: module 'requests' has no attribute 'get'
This is so weird, suddenly I can't run my code and all my work is halted.
I've been looking up the internet and saw that usually this happens if you call one of your files in a same name as a module (for example, naming my file bs4.py), I'm afraid this is not the case here, I made sure my file is named in a unique name which doesn't exist anywhere on said libraries.
I couldn't find any other solution for this.
Can anyone help me figure this one out?

How do I get a particular python module to work in Anaconda?

I don't have a lot of programming experience, so please try to keep answers relatively noob-friendly! :) Basically, I have a Python...library, I guess? or module? that I need to run in Spyder through Anaconda. This seems to be a very obscure module called PySPM, used for analyzing scanning probe microscopy data, that I received from a colleague my lab collaborates with. When I try to run a piece of software which uses this module, it gives this error:
ImportError: No module named 'PySPM.io'
The code itself which triggers this reads as follows:
from os import path
from PySPM.io.Translators.Utils import uiGetFile
from PySPM.io.Translators.BEPSndfTranslator import BEPSndfTranslator
from PySPM.io.Translators.BEodfTranslator import BEodfTranslator
from PySPM.analysis.BESHOFitter import BESHOFitter
The first line that says from PySPM.io.Translators.Utils import uiGetFile is what's triggering the error. I'm really stuck scratching my head here. What's going on and how can I solve it?
Pycroscopy is the (thoroughly) reorganized version of PySPM.
#Martensite try:
$ pip install pycroscopy

Urllb2 package missing from Pypi

I wanted to install urllib2 package from PyPI but it is not available.
It seems that it has been updated to urllib3, but is there any way to download urllib2 ?
import urllib2
Is that what you want?
If you find any library under http://docs.python.org/ you can always import without installing it.
Update 1:
If you need the source code...
The official Cpython code: http://hg.python.org/cpython/file/3b5fdb5bc597/Lib/urllib
Note The urllib2 module has been split across several modules in
Python 3 named urllib.request and urllib.error. The 2to3 tool will
automatically adapt imports when converting your sources to Python 3.
or try this? http://code.reddit.com/docs/urllib2-pysrc.html
I can't guarantee the integrity for the second alternative link.

Categories