Python Forum
Windows can't find installed packages
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Windows can't find installed packages
#1
I am trying to install some packages to my Windows Python 3.7

I downloaded BeautifulSoup, and then from the Windows cmd prompt, in the directory where the BS setup file exists, I ran python setup.pl install

This seemed to execute with no errors and completed.

However, when I use this in a script:

from bs4 import BeautifulSoup
I get this error:

File "c:/myscripts/test.py", line 1, in <module>
from bs4 import BeautifulSoup
ModuleNotFoundError: No module named 'bs4'

I've tried numerous packages but they all give similar errors.

Thanks in advance for your help.

I've tried
Reply
#2
TSheets13 Wrote:python setup.pl install
That's not the way we do it anymore,all is done bye pip.

Look at Python 3.6/3.7 and pip installation under Windows
Then it should work like this,i use virtual environment in this demo as i already have it installed.
# Check Python
(forum_env) E:\div_code\forum_env
λ python -V
Python 3.7.3

# Check pip
(forum_env) E:\div_code\forum_env
λ pip -V
pip 19.2.3 from e:\div_code\forum_env\lib\site-packages\pip (python 3.7)

# Install
(forum_env) E:\div_code\forum_env
λ pip install beautifulsoup4
Collecting beautifulsoup4
  Downloading .....
Installing collected packages: soupsieve, beautifulsoup4
Successfully installed beautifulsoup4-4.8.0 soupsieve-1.9.4

# Test that it work
(forum_env) E:\div_code\forum_env
λ python
Python 3.7.3 (v3.7.3:ef4ec6ed12, Mar 25 2019, 21:26:53) [MSC v.1916 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import bs4
>>> bs4.__version__
'4.7.1'

# The normal import you use
>>> from bs4 import BeautifulSoup
>>> 
Reply
#3
I seem to be unable to use pip

C:\Users\tsheet\Downloads\beautifulsoup4-4.8.0>pip install beautifulsoup4
Requirement already satisfied: beautifulsoup4 in c:\program files\python37\lib\site-packages\beautifulsoup4-4.8.0-py3.7.egg (4.8.0)
Requirement already satisfied: soupsieve>=1.2 in c:\program files\python37\lib\site-packages\soupsieve-1.9.4-py3.7.egg (from beautifulsoup4) (1.9.4)
Could not fetch URL https://pypi.org/simple/pip/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='pypi.org', port=443): Max retries exceeded with url: /simple/pip/ (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed certificate in certificate chain (_ssl.c:1056)'))) - skipping

Likely network security issue.

But interstingly I can get to https://pypi.org/simple/pip/ via the web browser. I followed instructions on downloading and installing packages manually. It does look like it satisfied some if not all requirements. But it still doesn't find bs4
Reply
#4
ATTENTION!!! THIS IS A COMPLETELY NEW AND DIFFERENT POST FROM THE PREVIOUS ONE HERE, BECAUSE I INADVERTENTLY ERASED THE PREVIOUS ONE WHILE TRYING TO ADD SOME COMMENTS!!!

I'm going to try to write again more or less what I had posted before with some added modifications ...

I'm going to explain, step by step, once again, how I installed BeautifulSoup. It is better to use pip:

1) I went to:

https://pypi.org/project/beautifulsoup4/

where on top of the page, you can see beautifulsoup4 4.8.0, and underneath that, pip install beautifulsoup4. Beside that, you can see an icon looking like two papers sheets, one on top of the other. If you click on this icon, you copy the command pip install beautifulsoup4 to your clipboard. (I prefer to do it this way, just in case I mistype something).

2) Now, on Windows cmd prompt, paste pip install beautifulsoup4 (or type directly if you prefer, pip install beautifulsoup4) and press the "ENTER" (or "RETURN") key and wait till the installation of beautifulsoup4 is completed:

[Image: to-install-beautiful-Soup.png]

[Image: beautiful-Soup-successfully-installed.png]

3) Now, as the previous program I had here, didn't seem to look for the desired word, I looked for more information, and on this site:

https://stackoverflow.com/questions/3339...n/33397525

I found an example program written in some Python 2. I adapted it to Python 3, and also made some changes to small bits that produced errors before. Now, no warnings or errors are produced. Forget about the previous program I had here, and use this other one. Copy and save this modified program, from the original one on that site:

# beautifulSoup_test_03.py
#
 
from bs4 import BeautifulSoup 
import re

data = '''
<html>
<body>
<div>today is a sunny day</div>
<div>I love when it's sunny outside</div>
Call me sunny
<div>sunny is a cool word sunny</div>
</body>
</html>
'''

searched_word = 'sunny'

soup = BeautifulSoup(data, 'html.parser')
results = soup.body.find_all(string=re.compile('.*{0}.*'.format(searched_word)), recursive=True)

print('Found the word "{0}" {1} times\n'.format(searched_word, len(results)))

for content in results:
    words = content.split()
    for index, word in enumerate(words):
        # If the content contains the search word twice or more this will fire for each occurrence
        if word == searched_word:
            print('Whole content: "{0}"'.format(content))
            before = None
            after = None
            # Check if it's a first word
            if index != 0:
                before = words[index-1]
            # Check if it's a last word
            if index != len(words)-1:
                after = words[index+1]
            print('\tWord before: "{0}", word after: "{1}"'.format(before, after))
4) Now, when I execute it, it produces the following output:
Output:
Found the word "sunny" 4 times Whole content: "today is a sunny day" Word before: "a", word after: "day" Whole content: "I love when it's sunny outside" Word before: "it's", word after: "outside" Whole content: " Call me sunny " Word before: "me", word after: "None" Whole content: "sunny is a cool word sunny" Word before: "None", word after: "is" Whole content: "sunny is a cool word sunny" Word before: "word", word after: "None" >>>
I hope it helps.

All the best,
newbieAuggie2019

"That's been one of my mantras - focus and simplicity. Simple can be harder than complex: You have to work hard to get your thinking clean to make it simple. But it's worth it in the end because once you get there, you can move mountains."
Steve Jobs
Reply
#5
Try:
python -m pip install --trusted-host pypi.python.org --trusted-host files.pythonhosted.org --trusted-host pypi.org --upgrade pip
Directly install.
pip install --trusted-host=pypi.org --trusted-host=files.pythonhosted.org beautifulsoup4
Bug, bug.

Using proxy.
pip install --proxy=http://yourproxy:yourport beautifulsoup4
Reply
#6
(Oct-02-2019, 03:10 PM)TSheets13 Wrote: I seem to be unable to use pip

C:\Users\tsheet\Downloads\beautifulsoup4-4.8.0>pip install beautifulsoup4
Requirement already satisfied: beautifulsoup4 in c:\program files\python37\lib\site-packages\beautifulsoup4-4.8.0-py3.7.egg (4.8.0)
Requirement already satisfied: soupsieve>=1.2 in c:\program files\python37\lib\site-packages\soupsieve-1.9.4-py3.7.egg (from beautifulsoup4) (1.9.4)
Could not fetch URL https://pypi.org/simple/pip/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='pypi.org', port=443): Max retries exceeded with url: /simple/pip/ (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed certificate in certificate chain (_ssl.c:1056)'))) - skipping

Likely network security issue.

But interstingly I can get to https://pypi.org/simple/pip/ via the web browser. I followed instructions on downloading and installing packages manually. It does look like it satisfied some if not all requirements. But it still doesn't find bs4
Hi!

I used to have also a lot of problems while I had Python not in the root directory. So I would advise you to write pip install beautifulsoup4 just after C:\> in your Windows cmd prompt. I would say that your system gets lost trying to find something among all those folders and subfolders ...

All the best,
newbieAuggie2019

"That's been one of my mantras - focus and simplicity. Simple can be harder than complex: You have to work hard to get your thinking clean to make it simple. But it's worth it in the end because once you get there, you can move mountains."
Steve Jobs
Reply
#7
I have discovered that if I save the python file and execute it from the command line with python, it works just fine. All libraries are found. It's when I try to use an IDE like IDLE or PyCharm it doesn't work. Perhaps I need to configure something in the IDE's that I missed.
Reply
#8
(Oct-02-2019, 05:52 PM)TSheets13 Wrote: All libraries are found. It's when I try to use an IDE like IDLE or PyCharm it doesn't work. Perhaps I need to configure something in the IDE's that I missed.
Configure a Python interpreter
When talking about interpreter,it's the location of python.exe or folder it's in.
So if do this get the path to python version that work from command line,then set same version in configure link.
C:\>python -c "import sys; print(sys.executable)"
C:\python37\python.exe

C:\>pip -V
pip 19.2.3 from c:\python37\lib\site-packages\pip (python 3.7)

C:\>
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Python Launcher (on Windows) only necessary when 2 or more Python versions installed? pstein 1 317 Feb-17-2024, 12:43 PM
Last Post: deanhystad
  How to find out from outside Python (in Windows) the current version of Python? pstein 4 736 Oct-04-2023, 10:01 AM
Last Post: snippsat
  How do I find the 64 bit download for Windows? Blackwood 1 1,492 Aug-18-2020, 11:19 AM
Last Post: snippsat
  how to find module in installed packages keuninkske 3 3,196 May-09-2020, 10:21 PM
Last Post: keuninkske
  [split] Windows can't find installed packages deep_logic 11 5,452 Nov-26-2019, 10:39 PM
Last Post: snippsat
  pycharm cannt find dlib which is installed kevinlee325 2 4,297 Oct-15-2019, 04:56 AM
Last Post: kevinlee325
  Python can't find module installed in anaconda iFunKtion 12 54,487 Mar-06-2019, 05:15 PM
Last Post: jwsmallz
  Windows cannot find "wish.exe" - error while trying to run PAGE Nwb 0 7,525 Jun-11-2018, 12:08 PM
Last Post: Nwb
  Even 3.5.4 can not be installed in my Windows 7 kwfine 2 2,704 Feb-07-2018, 12:46 PM
Last Post: metulburr

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020