I have installed a python library but dreampie won't import it - python-3.3

I have installed a python library in python3.3. When I run the interpreter in Dreampie, it can't find my newly-installed library, resulting in an error like:
>>> from bs4 import BeautifulSoup
Traceback (most recent call last):
File "<pyshell#4>", line 1, in <module>
from bs4 import BeautifulSoup
ImportError: No module named 'bs4'

This is a dreampie 1.2.1 bug. To work around it, under Edit | Preferences | Shell, add the following line to the automatically-run code in the black box:
import site
site.main()

Related

I'm struggling to get 'beautifulsoup4' working in pycharm on my windows10 laptop

Pycharm seems to accept bs4 but doesn't recognize beautiful soup - even though i've made sure it is installed via pip in the command terminal and via miniconda. I've also gone to settings (in pycharm) and
have the packages bs4 and beautifulsoup4 installed already (with the latest versions), I am using Python 3.9.
The following is the error message I get:
C:\Users\joe_h\AppData\Local\Programs\Python\Python39\python.exe C:/Users/joe_h/AppData/Roaming/JetBrains/PyCharmCE2020.3/scratches/scratch.py
Traceback (most recent call last):
File "C:\Users\joe_h\AppData\Roaming\JetBrains\PyCharmCE2020.3\scratches\scratch.py", line 1, in <module>
from bs4 import beautifulsoup4
ImportError: cannot import name 'beautifulsoup4' from 'bs4' (C:\Users\joe_h\AppData\Roaming\Python\Python39\site-packages\bs4\__init__.py)
Process finished with exit code 1
Instead of trying
from bs4 import beautifulsoup4
(which is wrong way to do it)
instead do
from bs4 import BeautifulSoup

Cannot import installed python package (MacOS)

I cannot import any python package when running python on Visual Studio code or on my Terminal. I can still do this if I were to code on a Jupyter notebook. However, when I tried other environment that doesn't use the notebook server. It returns me ModuleNotFound Error like this
Traceback (most recent call last):
File "/Users/truongminh/Desktop/DataScience/Datasets/CityU Text/test_PreprocessText.py", line 1, in <module>
import PreprocessText
File "/Users/truongminh/Desktop/DataScience/Datasets/CityU Text/PreprocessText.py", line 1, in <module>
import pandas as pd
ModuleNotFoundError: No module named 'pandas'
Most of my packages was download via anaconda. I don't know if it might be the cause of this.

How can I import bs4 from Beautiful Soup in Python3 on OSX 10.12.5?

I'm trying to fix what seems like a common problem with importing a module in Python 3. I'm running OS X 10.12.5 and have Python 3 installed on my MacBook Air and am using Sublime Text to edit and run my code.
When I try this import:
from bs4 import BeautifulSoup
...I get this error:
Traceback (most recent call last):
File "/Users/<myname>/Python/code-python3/Pgm#001", line 5, in <module>
from bs4 import BeautifulSoup
ImportError: No module named 'bs4'
I successfully installed with this PIP and on every re-install I see this:
$ pip install beautifulsoup4
Requirement already satisfied: beautifulsoup4 in ./anaconda/lib/python3.5/site-packages
I've tried qualifying the location with things like:
from ./anaconda/lib/python3.5/site-packages/bs4 import BeautifulSoup
...but invariably get a variety of syntax errors; usually on the first '/'.
I am not using a virtual environment but do plan to read up on that approach as these kind of configuration and setup errors are big time wasters.
When I try to run this right in python3 I get slightly different errors:
>>> from bs4 import BeautifulSoup
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/<myname>/anaconda/lib/python3.5/site-packages/bs4/__init__.py", line 30, in <module>
from .builder import builder_registry, ParserRejectedMarkup
File "/Users/<myname>/anaconda/lib/python3.5/site-packages/bs4/builder/__init__.py", line 314, in <module>
from . import _html5lib
File "/Users/<myname>/anaconda/lib/python3.5/site-packages/bs4/builder/_html5lib.py", line 70, in <module>
class TreeBuilderForHtml5lib(html5lib.treebuilders._base.TreeBuilder):
AttributeError: module 'html5lib.treebuilders' has no attribute '_base'
Any tips about where the obvious answer exists that I am still missing would be greatly appreciated. I've seen a lot of things about PATH and PYTHONPATH in similar questions but had no success with any of these solutions either.
Yes, I'm not a fan of anaconda but looks like the path is being pointed to:
"/Users//anaconda/lib/python3.5/site-packages"
... and for the sake of keeping things as clean as possible (this being a good example/reason why you'll see people say to use env for your python projects)
Lets google here! Here's how to remove anaconda:
conda install anaconda-clean #first the configs
anaconda-clean --yes
rm -rf ~/anaconda.* #then conda, the ".*" is regex to cover any version
The check your bash_profile and/or bashrc; and here you can set your Python path. Make sure it not pointing to anaconda
if you run
ls -lh `which python # orpython3
You'll get the path of which is the one you'll be setting as the path.

Can't import urilib.request in atom-runner

My OS is ubuntu 14.04
Here is my code
from urllib.request import urlopen
html=urlopen("https://github.com/")
print(html.read())
And in ATOM with atom-runner I get this
Traceback (most recent call last):
File "/home/ryan/PYTHON/runnertest.py", line 1, in <module>
from urllib.request import urlopen
ImportError: No module named request
I have set the config of ATOM like this
runner:
python: "/usr/bin/python3"
and when I import other modules like random, there is nothing wrong.
But when I run this code in Sublimetext3 with SublimeREPL(I set it before to run python3) It's OK
So what is the problem?.?
THX!!
nailed it by change the config into:
'runner':
'scopes':
'python':'python3'

beautifulsoup 4.4 on python 3.5

I am having issues on a new PC and cannot find an answer anywhere. I am trying to get beautifulsoup 4.4 to work on python 3.5. I am using pyCharm - I am reading that they may not be compatible but I have the same setup on my laptop and it works perfectly - only difference is the PC I am trying get BS to work on is Windows 7 where my laptop is Windows 8.
When I go into settings and look at Project Interpreter I do see BS 4.4.1 but when I try and run something I am getting this error:
Traceback (most recent call last):
File "C:/Users/PP/PycharmProjects/Shark/NOCO.py", line 3, in <module>
from bs4 import BeautifulSoup
File "C:\Users\PP\AppData\Local\Programs\Python\Python35-32\lib\site-packages\bs4\__init__.py", line 29, in <module>
from .builder import builder_registry
File "C:\Users\PP\AppData\Local\Programs\Python\Python35-32\lib\site-packages\bs4\builder\__init__.py", line 294, in <module>
from . import _htmlparser
File "C:\Users\PP\AppData\Local\Programs\Python\Python35-32\lib\site-packages\bs4\builder\_htmlparser.py", line 7, in <module>
from html.parser import (
ImportError: cannot import name 'HTMLParseError'
You are not running BeautifulSoup 4.4.1; your traceback shows you have an older version.
In 4.4.1, that section looks like this:
try:
from html.parser import HTMLParseError
except ImportError as e:
# HTMLParseError is removed in Python 3.5. Since it can never be
# thrown in 3.5, we can just define our own class as a placeholder.
class HTMLParseError(Exception):
pass
Line 7 is try:. This change was made in 4.4.0, so you have 4.3.2 or older installed instead.
Upgrade your installed package. PyCharm can do this, or you can use pip:
python3 -m pip install -U beautifulsoup4

Resources