beautifulsoup4 doesn´t work - python

I´ve already installed beautifulsoup4 but it doesn´t work.
This is the second time I try to install:
(k36) C:\GROWTHTECH\Projetos\blockchain>python -m pip install beautifulsoup4
Requirement already satisfied: beautifulsoup4 in c:\users\patff\appdata\local\conda\conda\envs\k36\lib\site-packages\beautifulsoup4-4.6.0-py3.6.egg
You are using pip version 9.0.1, however version 10.0.1 is available.
You should consider upgrading via the 'python -m pip install --upgrade pip' command.
When I made a test:
>>> import beautifulsoup4
Traceback (most recent call last):
File "<console>", line 1, in <module>
ModuleNotFoundError: No module named 'beautifulsoup4'
>>> from BeautifulSoup import BeautifulSoup
Traceback (most recent call last):
File "<console>", line 1, in <module>
ModuleNotFoundError: No module named 'BeautifulSoup'
>>> exit()

The official import name of BeautifulSoup was changed to bs4 in version 4 [1] [2]. If it is installed correctly otherwise, import the package by calling:
import bs4

Related

Showing error while installing BeatifulSoup

while pip installing BeautifulSoup it is showing this:-
C:\Users\LENOVO>pip install beautifulsoup4
Requirement already satisfied: beautifulsoup4 in
c:\users\lenovo\anaconda3\lib\site-packages (4.9.3)
Requirement already satisfied: soupsieve>1.2; python_version >= "3.0" in
c:\users\lenovo\anaconda3\lib\site-packages (from beautifulsoup4) (2.0.1)
C:\Users\LENOVO>
But while importing this library it is showing this error message:-
>>>from bs4 import BeautifulSoup
Traceback (most recent call last):
File "<pyshell#1>", line 1, in <module>
from bs4 import BeautifulSoup
ModuleNotFoundError: No module named 'bs4'
>>>
I have only Python3 installed in my system. Please Help :-)
Python loads modules from location in sys.path. So probably worth calling that and seeing where it is looking for modules. E.g. for my system (in a virtualenv)
In [9]: sys.path
Out[9]:
['/Users/me/.virtualenvs/standard/bin',
'/Users/me/.virtualenvs/standard/lib/python37.zip',
'/Users/me/.virtualenvs/standard/lib/python3.7',
'/Users/me/.virtualenvs/standard/lib/python3.7/lib-dynload',
'/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/lib/python3.7',
'',
'/Users/me/.virtualenvs/standard/lib/python3.7/site-packages',
'/Users/me/.virtualenvs/standard/lib/python3.7/site-packages/IPython/extensions',
'/Users/me/.ipython']
and checking that c:\users\lenovo\anaconda3\lib\site-packages is in that list

Python cannot find module, pip list does

So, this was my first time making a python package. I tried and tested and got it to work. This meaning that pip install . didn't complain and that
$sudo python3
>>>from LEDController import prettyLight
>>>prettyLight().light('whatsapp',100)
provided expected output and actions in my LED matrix.
Also pip list includes LEDControllerm but as soon as I start python3 anywhere but in the LEDController package directory, the module is not being found.
Running pip install /path/to/LEDController/ is still successfull, as is pip3 install /path/to/LEDController/.
Yet I get
$sudo python3
>>> import LEDController
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'LEDController'
>>> from LEDController import prettyLight
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'LEDController'
What am I missing?
As #sinoroc said, installing only using pip is not the safest option. Instead using python3 -m pip install /path/to/module fixed the issue perfectly.
I'll put his link here so future viewers can read up on why this is.

Pyglet import not found when using pip

Ok so I'm trying to install pyglet using pip3 and I've used the command pip3 install pyglet and it works it's in my /usr/local/lib/python3.7/site-packages (1.4.9) and I am using python 3.7. I have successfully imported things using pip before, I've tried uninstalling and reinstalling... I'm not sure what the problem is the error message is
Traceback (most recent call last):
File "/Users/myname/Documents/plz.py", line 1, in <module>
import pyglet
ModuleNotFoundError: No module named 'pyglet'

Python 2.7 import requests issue

I've tried to install requests module (Debian, Python 2.7) by pip install requests command. Output was:
Installing collected packages: urllib3, requests
Successfully installed requests-2.18.4 urllib3-1.22
Tried following the following Quickstart tutorial but I get the following error at import requests
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "requests/__init__.py", line 76, in <module>
check_compatibility(urllib3.__version__, chardet.__version__)
AttributeError: 'module' object has no attribute '__version__'
Any help?
Problem was with chardet package. Uninstalled it (pip uninstall chardet) and installed again and now it works. Cheers!

No module named 'bs4'

I want to import BeautifulSoup. But there is a problem. The BeautifulSoup library has installed in anaconda.
C:\Users\q>pip install BeautifulSoup4
Requirement already satisfied: BeautifulSoup4 in c:\users\q\anaconda3\lib\site-packages
But when i want to import BeautifulSoup, it trigger an error.
from bs4 import BeautifulSoup
Here is result
Traceback (most recent call last):
File "C:\Users\q\pyfile\ipsearch.py", line 1, in <module>
from bs4 import BeautifulSoup
ModuleNotFoundError: No module named 'bs4'
Why? The reason is to the path of python's site-packages and the path to anaconda's site-packages trigger a confilct? A month ago, i use it successfully, at that time, my computer has installed python3.5 and anaconda. But now, it trigger an error. Why? Thanks for your answer.
try following command:
pip install --ignore-installed beautifulsoup4

Categories

Resources