Windows can't find installed packages - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: Windows can't find installed packages (/thread-21506.html) |
Windows can't find installed packages - TSheets13 - Oct-02-2019 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 BeautifulSoupI 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 RE: Windows can't find installed packages - snippsat - Oct-02-2019 TSheets13 Wrote:python setup.pl installThat'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 >>> RE: Windows can't find installed packages - TSheets13 - Oct-02-2019 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 RE: Windows can't find installed packages - newbieAuggie2019 - Oct-02-2019 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: 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/33396785/how-to-find-a-particular-word-in-html-page-through-beautiful-soup-in-python/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: I hope it helps.All the best, RE: Windows can't find installed packages - snippsat - Oct-02-2019 Try: python -m pip install --trusted-host pypi.python.org --trusted-host files.pythonhosted.org --trusted-host pypi.org --upgrade pipDirectly install. pip install --trusted-host=pypi.org --trusted-host=files.pythonhosted.org beautifulsoup4Bug, bug. Using proxy. pip install --proxy=http://yourproxy:yourport beautifulsoup4 RE: Windows can't find installed packages - newbieAuggie2019 - Oct-02-2019 (Oct-02-2019, 03:10 PM)TSheets13 Wrote: I seem to be unable to use pipHi! 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, RE: Windows can't find installed packages - TSheets13 - Oct-02-2019 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. RE: Windows can't find installed packages - snippsat - Oct-02-2019 (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:\> |