Python Forum

Full Version: Invalid Syntax error
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
When I run the following I'm getting an error message. Anyone knows how to correct it?


>>> import requests
>>> from bs4 import BeautifulSoup
Error:
Traceback (most recent call last): File "<stdin>", line 1, in <module> File "C:\Users\mustf\AppData\Local\Programs\Python\Python37\bs4\__init__.py", line 52 'You are trying to run the Python 2 version of Beautiful Soup under Python 3. This will not work.'<>'You need to convert the code, either by installing it (`python setup.py install`) or by running 2to3 (`2to3 -w bs4`).' ^ SyntaxError: invalid syntax
how did you install bs4?
I'm on Windows10. I used the following:

C:\Users\mustf\AppData\Local\Programs\Python\Python37\Scripts>pip install beautifulsoup4
Requirement already satisfied: beautifulsoup4 in c:\users\mustf\appdata\local\programs\python\python37 (4.8.0)
Requirement already satisfied: soupsieve>=1.2 in c:\users\mustf\appdata\local\programs\python\python37\lib\site-packages\soupsieve-1.9.4-py3.7.egg (from beautifulsoup4) (1.9.4)
that is weird. try to uninstall it and install again
pip uninstall beautifulsoup4
and then
pip install beautifulsoup4
by any chance do you have multiple python installations?
Cannot be uninstalled. I tried the these :'(

Error:
C:\Users\mustf\AppData\Local\Programs\Python\Python37\Scripts>pip uninstall beautifulsoup4 Can't uninstall 'beautifulsoup4'. No files were found to uninstall.
Error:
C:\Users\mustf\AppData\Local\Programs\Python\Python37\Scripts>pip uninstall BeautifulSoup WARNING: Skipping BeautifulSoup as it is not installed.
I guess you did something you don't tell us. i.e. if it was install via pip install beautifulsoup4 as you claim, e.g. did you move something between folders?
I moved the content of C:\temp\beautifulsoup4-4.8.0
to C:\Users\mustf\AppData\Local\Programs\Python\Python37\Scripts
then install BS using PIP.

I fixed the issue. I uninstalled Python and removed the folders and reinstalled everything from scratch.
(Oct-07-2019, 06:32 PM)mustfirst Wrote: [ -> ]I moved the content of C:\temp\beautifulsoup4-4.8.0
that was the problem. don't do such things. always follow instructions on how to install (in most cases just pip install <package>) would do)

(Oct-07-2019, 06:32 PM)mustfirst Wrote: [ -> ]then install BS using PIP.
in fact you didn't install anything
Hi all,
It seems like I have the same problem as @mustf. I have python3.7 installed and have my windows environment variable set up to run from a cmd prompt. I have MSVS 2019 installed that seems to have some of the beautifulsoup4 modules. I have pycharm installed as well.
When I run pip from the cmd line and install bs4, it is listed as installed.
But, when I open idle, I list the modules, it's not listed their.
Maybe, I should uninstall pycharm or MSVS 2019?
I'm on windows10.
Thanks for any help