Unable to import beautifulsoup4 module in Termux - python

Here's the full log which shown that I'm unable to import beautifulsoup4
$ python
Python 3.7.5 (default, Oct 23 2019, 08:30:10)
[Clang 8.0.7 (https://android.googlesource.com/toolchain/clang b55f2d4ebfd35bf6 on linux
Type "help", "copyright", "credits" or "license" for more information.
import bs4
from bs4 import beautifulsoup4
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: cannot import name 'beautifulsoup4' from 'bs4' (/data/data/com.termux/files/usr/lib/python3.7/site-packages/bs4/__init__.py)
import beautifulsoup4
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'beautifulsoup4'

This works for me:
>>> from bs4 import BeautifulSoup
>>>

Related

ImportError: No module named parse even after installing dataset and parse

I get the following error. I also installed PIP Parse and dataset using PIP install
Python 2.7.14 (v2.7.14:84471935ed, Sep 16 2017, 20:25:58) [MSC v.1500 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import dataset
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Python27amd64\lib\site-packages\dataset\__init__.py", line 3, in <module>
from dataset.database import Database
File "C:\Python27amd64\lib\site-packages\dataset\database.py", line 3, in <module>
from urllib.parse import parse_qs, urlparse
ImportError: No module named parse

ete3 module on python3 - cannot import TreeStyle, faces, AttrFace, NodeStyle

I a linux user and so far I've using ete3 in python2 succesfully.
I installed ete3 for python3 and there are certain modules that python3 can't find. I believe I have all the dependencies installed according to the instructions.
I can import ete3, and Tree from ete3 but not any other that I've using so far.
Any clues on how to resolve this?
~$ python3
Python 3.4.3 (default, Nov 28 2017, 16:41:13)
[GCC 4.8.4] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import ete3
>>> from ete3 import Tree
>>> from ete3 import TreeStyle
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: cannot import name 'TreeStyle'
>>> from ete3 import faces
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: cannot import name 'faces'
>>> from ete3 import AttrFace
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: cannot import name 'AttrFace'
>>> from ete3 import NodeStyle
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: cannot import name 'NodeStyle'
I managed to install the dependencies. The problem was that ete3 is not reporting properly the missing dependencies.
You can see which dependencies are missing with this code:
import ete3
ete3.__file__
I run it multiple times and install the packages that was complaining about each time until it finally worked!

unable to import BeautifulSoup (python 3.6 and bs4-4.1.0)

I have installed bs4 on my system successfully (using python setup.py install).
Now the problem is while importing BeautifulSoup in python I'm getting below errors:
C:\Users\dipankar>python
Python 3.6.3 (v3.6.3:2c5fed8, Oct 3 2017, 18:11:49) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from bs4 import BeautifulSoup
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\dipankar\AppData\Local\Programs\Python\Python36\lib\site-packages\bs4\__init__.py", line 29, in <module>
from .builder import builder_registry
File "C:\Users\dipankar\AppData\Local\Programs\Python\Python36\lib\site-packages\bs4\builder\__init__.py", line 294, in <module>
from . import _htmlparser
File "C:\Users\dipankar\AppData\Local\Programs\Python\Python36\lib\site- packages\bs4\builder\_htmlparser.py", line 7, in <module>
from html.parser import (
ImportError: cannot import name 'HTMLParseError'
>>>
After doing a lot of google searches
pip install --upgrade beautifulsoup4
worked for me.
As you can read here
because HTMLParseError is deprecated from Python 3.3 onwards and
removed in Python 3.5.
I will recommend you to use other parser. Check BeautifulSoup Documentation

Import framenet from nltk.corpus(.reader) in python2.7: ImportError

I noticed that I cannot import framenet from nltk.corpus.reader or from nltk.corpus and understood that it is available in newer versions of NLTK.
$ python
Python 2.7.5+ (default, Sep 19 2013, 13:48:49)
[GCC 4.8.1] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import nltk
>>> nltk.__version__
'3.0a2'
But the nltk.downloader shows an entry for framenet_v15 and in the filesystem I have a directory framnet_v15.
So why can I not import it?
>>> from nltk.corpus import framenet
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: cannot import name framenet
>>> from nltk.corpus.reader import framenet
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: cannot import name framenet
As you can see: framenet corpus is already installed
Example
#!/usr/bin/env python
from nltk.corpus.reader import framenet
Installation
Download NLTK 3.0
tar -xzvf ntlk-3.0a3.tar.gz
cd nltk-3.0a3/
sudo python setup.py install
Execution
./example.py

Python Import Error when importing tests from django-social-auth

I'm trying to subclass some classes from the django-social-auth package to create custom test.
The source https://github.com/omab/django-social-auth
The problem is that i cannot import the "tests" part:
C:\Users\Alle>python
Python 2.6.6 (r266:84297, Aug 24 2010, 18:46:32) [MSC v.1500 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import social_auth.tests.base
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named tests.base
>>> import social_auth.tests
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named tests
>>> import social_auth.db
>>> social_auth.db
<module 'social_auth.db' from 'C:\Python26\lib\site-packages\social_auth\db\__init__.pyc'>
>>>
why i get this behaviour?
Tests aren't installed by default
from social_auth setup.py
packages=['social_auth',
'social_auth.management',
'social_auth.management.commands',
'social_auth.backends',
'social_auth.backends.contrib',
'social_auth.backends.pipeline',
'social_auth.migrations',
'social_auth.db'],

Categories