Pycharm not recognizing installed BeautifulSoup4 module - python

I have trouble with Pycharm recognizing installed modules. I'm using Pycharm 2018.2.4 CE with Python 3.7 x64, on Windows 10. I don't have Python 2.x installed. I installed requests and BeautifulSoup4 from command line using 'pip' and 'pip3' commands. Pip list and Pycharm is seeing installed module in interpreters list but when I enter my code is grayed out like none of those were installed:
Grayed out code
Interpreter settings
I tried everything - reinstalling both Python (x64 and x86) and Pycharm, installing/upgrading/uninstalling BeautifulSoup4 and bs4, I also tried every solution I could find on stack or google, seems like few people had similar issue but no one gave them any final answer. Does anyone know how to fix this under Windows 10?

See if this helps:
Go to the following path:
File/ Settings/ Project: Project_Name/ Project Interpreter
Click on the plus sign on the right, find the module there and install it.
Also, if they are gray, it's because you have imported them but haven't used them yet. The only one which might have a problem is the last one with the red lines maybe.
This was discussed here
Also, below should be changed
from bs4 import BeautifulSoup

Related

BeautiulSoup4 Installation issue in VSCode

I've BeautifulSoup4 installed in my system but when I import it, I get thrown an error No module named 'beautifulsoup4'. I just installed this module as shown in the screenshot attached. .
In addition, I've tried the regular pip install method to install BeautifulSoup4 but same issue.
Maybe you are not in the version you installed beautifulSoup4. Try positioning yourself in the python version you intalled it.
try changing the version you are working on with in visual:
Look for this, and click it
you may have two options like so:
select the one you are not positioned in

Errors importing module after using Pip to install with Python 3.9

Apologies, but I'm a total python newbie and I'm really stuck with this. I've got Python 3.9 on a PC, and am learning to code using PyCharm as my editor. I've used Pip to import numpy but I'm getting an error when I add "import numpy" to my script:
ModuleNotFoundError: No module named 'numpy'
It looks like Pip downloaded it okay, and put it into the folder:
C:\Users\Alastair Heptonstall\AppData\Local\Programs\Python\Python39\Lib\site-packages\numpy
PyCharm appears to be using the correct version of python (it has Python 3.9 in the lower right corner of the screen). And it looks like the version of Pip I used is the one that came with Python 3.9.
Is this error caused by a path not being set correctly?
Thanks for any help, very much appreciated!
You can try this
1. Open PyCharm.
2. go to File -> settings -> Project:untitled1 (untitled1 means your project name) -> select project interpretor -> click add button
3. after clicking add button and search <package name> then install it.
finally, run the program.
Newer versions of Pycharm have a "+" mark (add button) here.

Getting PyCharm to import sklearn

Beginner here.
I’m trying to use sklearn in pycharm. When importing sklearn I get an error that reads “Import error: No module named sklearn”
The project interpreter in pycharm is set to 2.7.10 (/anaconda/bin/python.app), which should be the right one.
Under default preferenes, project interpreter, I see all of anacondas packages. I've double clicked and installed the packages scikit learn and sklearn. I still receive the “Import error: No module named sklearn”
Does anyone know how to solve this problem?
To make sure you have Scikit-learn package installed on your PyCharm IDE, go to File Menu>Settings and search for Interpreter. Select Project Interpreter, and if you dont see Scikit-learn in the list of packages, click the + sign on the right end. It brings us another window with a search bar, where you can type 'Scikit-learn' and install (see screenshots). I hope this helps.
Screenshots:
,
please notice that, in the packages search 'Scikit-learn', instead 'sklearn'
go to terminal- type python -m pip install scikit-learn
then hit enter.
give it some seconds. It will be done.
Sample Image
Double check your python interpreter. Check whether you have select correct interpreter at the first when you create the project.
Or else you can check your interpreter from the project view under External Libraries.
In your case if you didn't select 2.7.10 (/anaconda/bin/python.app) as your interpreter for the project at the beginning still the program give the same error Import error: No module named sklearn.
Same error occurs to me i have fixed by selecting File Menu-> Default Settings-> Project Interpreter -> Press + button and type 'sklearn' Press install button. Installation will be done in 10 to 20 seconds.
If issue not resolved please check you PyCharm Interpreter path. Sometimes your machine have Python 2.7 and Python 3.6 both installed and there may be some conflict by choosing one.
I had exactly the same problem. I'm using PyCharm with Anaconda3 & Python 3.7, and I've installed other packages into/via PyCharms just fine (such as numpy, scipy, and others). But although scikit-learn (which contains sklearn, that was initially confusing) seems fully installed on my system, including "import sklearn" working outside of PyCharm, I could not get the "import sklearn" to succeed inside PyCharm.
I finally got a python-expert friend to help me. He verified everything was correctly installed on my system and verified that PyCharm was somehow messing up.
We finally determined that the venv (virtual environment) was not including scikit-learn (sklearn) even though I had imported it properly into the Project Interpreter in PyCharms.
Solution: Delete and recreate the VENV, specifically ticking the box Inherit Global Site Packages
See here: https://www.jetbrains.com/help/pycharm/creating-virtual-environment.html
for how to create a new virtual environment and get to that parameter.
SOLVED:
reinstalled Python 3.7.9 (not the latet)
installed numpy 1.17.5 (not the latest)
installed scikit-learn (latest)
sklearn works now!
For Mac OS:
PyCharm --> Preferences --> Project Interpreter --> Double Click on pip (a new window will open with search option) --> mention 'Scikit-learn' on the search bar --> Install Packages --> Once installed, close that new window --> OK on the existing window
and you are done.

How to solve "Unresolved import: HTML" in Python Development?

I'm starting to learn about python development in a new project.
I got setup almost everything right, but only this import HTML that keeps given me some error that I don't know how to solve it.
import web
import json
from WebServer.forms import mainPageForm, addBugForm, addProblemForm, addProblemTypeForm, versionsDropdownForm,\
severitiesDropdownForm, problemTypesDropdownForm, problemsDropdownForm
import BugRecorderCore.controller as ctrl
import BugRecorderCore.validators as vdt
import datetime
import os
from BugRecorderCore.utils import concatenateString
import HTML
//...
I already tried to install HTML.py already, but still no success so far.
Any idea or advice about this issue ?
UPDATE
Following the suggestions from the answers below I got this message:
It looks like you are using anaconda, have you tried installing it the anaconda way?
conda install HTML
Also do you by any chance have 2 version of Python on your system?
If the package is unavailable you'll have to user pip. If you don't have pip, from your command line write:
python get-pip.py
pip install HTML
Looking the given screenshots and tags I suppose your are using Anaconda (which I have no experience but it is still Python, anyway) and the IDE is not resolving the import.
Make sure you have installed/updated HTML.py
conda install HTML
At your IDE go to Window > Preferences > Python Interpreter
At Libraries tab make sure you have the following folders added to your PYTHONPATH:
C:\Anaconda\Lib
C:\Anaconda\Lib\site-packages
C:\Anaconda\Scripts
That should do the trick.
Important: try to always install your libraries through conda (or pip when using Python directly). It will install things where it should be. ;)

'Web' module cannot be found while having installed lpthw.web

I'm currently doing the exercise in "Learn python the hard way".
In this exercise i have to install the lpthw.web frame work.
Having installed pip in windows, i open my terminal and hit
pip install lpthw.web
Everything then ends succesfully.
But when i browse C:\Python27\Lib\site-packages\lpthw.web-1.1-py2.7.egg-info and check the installed-files text i can't see the web.py.
Consequently when i try to import it in a simple script i get ImportError.
I don't have python 3 installed as book suggested for possible cause, so i don't know how to work around it.
Any suggestion?
I checked my path
import sys
sys.path
and saw that every single line was using the panda3d path.
As i was not really using it, unistalling it fixed my problem.
For me it was python version control on raspberry pi
(linux) 2.7 is default and does not work.
follow:
https://learn.sparkfun.com/tutorials/python-programming-tutorial-getting-started-with-the-raspberry-pi/configure-your-pi
have other errors now but the import web loads in python.
cheers!

Categories