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

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. ;)

Related

I’m not able to import my pip module after installing it from my CMD

I just installed camelcase using the pip command on my cmd.
When I try pip list, the module is present but when I try to import it to my text editor, it tells me that it does not exist.
I installed another module and I was able to import it.
I’ve tried uninstalling and reinstalling it again but it’s not still working.
Which code editor are you using? In my case when I had similar problems with installing packages I tried installing them directly from terminal in my PyCharm app. For me it worked out perfectly.
Make sure you are importing the right class.
from camelcase import CamelCase

Can't import modules in python after installing them with pip

I am trying to use the pyserial module in my python project, so i installed it with pip install pyserial. After doing that, I did import pyserial in my python interpreter and it gave me this error:
Pyserial appears in my pip list list, and when i do pip show pyserial it gives this result:
I think you're using a wrong import statement, import pyserial will give you and should give you the above error .
The correct import statement is import serial, so try this instead.
Always it's a good thing to read the documentation, you can read more about pyserial on the docs here
Pycharm has a different way to install packages. You shouldn't install them via pip. I'm not sure why pip doesn't always install packages properly is though.
Instead, you can install it by opening the tool page in the main menu. This is available for PyCharm 2021.1 and later.
View -> Tool Windows -> Python Packages -> Search
You can also open the project interpreter to install packages.
Settings (CTRL+ALT+S) -> Project_Name -> Python Interpreter -> + (symbol at bottom) -> Search
See this article for a more complete tutorial.
I fixed this problem in PyCharm by typing import serial and it gave me an option to auto-install it. I took that option, and it worked.

I have pyPDF2 installed on my interpreter that has venv and uses python 3.6.6 but i'm not able to import it. What am I doing wrong?

I have pyPDF2 installed on my interpreter that has venv and uses python 3.6.6 but i'm not able to import it. What am I doing wrong? I use pycharm.
Try using
import PyPDF2
Python is case sensitive.
I found the solution. But before I answer that, I have to re-iterate that -
NO, Pycharm wasn't detecting the module even when I tried
import pyPDF2
Solution:
Uninstall pyPDF2, re install it, and this time install it through the
IDE through that pop-up (refer to example screenshot)
I found this weird as I don't usually install modules this way.

ModuleNotFoundError: No module named 'bs4' but I have bs4 installed I believe

So I am not able to import BeautifulSoup after I have installed bs4.
I have tried installing bs4 using pip, pip3, and pip3.6. All successfully install bs4, but I still get the error saying there is no module named bs4 when I try and import it.
I have also tried doing it by using "pip install beautifulsoup4" with no luck.
I am using python 3.6.5 on Windows 10.
This is the output of my pip commands
Let me know things I can try differently to get this working.
Thanks for any help.
Had two installs of Python. Man I feel like an idiot haha. The second install was hidden in a visual studio folder.
I had a similar issue - but switched my interpreter (in pycharm) from the 'local' to the global python scripts.
Successful running of script on local html files and on requests.
Thank you to this thread and one other for helping me fix the issue.

Python packages are imported on terminal but not on IDLE

So I am new in Python. I downloaded Anaconda (and Homebrew) and using Terminal on my Mac I confirmed that, say, Numpy is installed:
pip install numpy
to get as a result
Requirement already satisfied: numpy in ./anaconda/lib/python3.6/site-packages
Then opening Python within Terminal I can indeed import the package. The story is not the same once I open IDLE. So when I open it and try to import, say, Numpy I get the following message:
Traceback (most recent call last):
File "<pyshell#1>", line 1, in <module>
import numpy
ModuleNotFoundError: No module named 'numpy'
I guess there is something I do not know, I assume it is a common rookie problem. Can you help me with this?
Since your IDLE is using Python 3 you should use
pip3 install numpy
to get it installed for the correct Python. If you want to use your default installed Python (2.x) instead, IDLE is located at /usr/bin/. From your terminal you can open it with
/usr/bin/idle
this should have the numpy you installed with pip install numpy
See when you are working with Anaconda it creates its own virtual environment.
Now, If you are new in python on MAC then you might not familiar with Virtual Environment.
I suggest you to download python from the official website www.python.org
or Click here to directly download Python 3.6.2 on your MAC.
Then, Download Pycharm(The Best IDE for Python)
Download the community version for beginner and it is also free.
Pycharm Community Version -> Click Here
And do whatever you want and also must read about Virtualenv
According to me, Pycharm is better then Anaconda's Jupyter Notebook
Wish you good luck and show your creativity in python ! !
Erm... well it appears as though - since you have 2 versions on your computer - that it might be because it imported it into the other file path directory. Now, I've never worked with Mac, but I think if you just specify which pip you want to download from, it might work.
For example, on Windows:
C:\Python34\Scripts\pip.exe install numpy
or if you were doing it for 3.6, you would follow the path to the folder, find pip and install. So, I suggest to install the normal IDLE before any other platform built upon it just because it is easier to import modules and is not as bad to break like yours has.
There can be two issues -
You are using python 2 as a kernel for IDLE, since numpy is installed for python3.6. This will raise an error.
The issue is with anaconda's configuration with IDLE. Anaconda installs numpy in ./anaconda/lib/python3.6/site-packages. If IDLE uses systems default python instead of anaconda's. You will not be able to import numpy.
You can try running this snippet -
import sys
print('\n'.join(sys.path))
to track the location of python exactly.
One of the workaround that I can think of is -
create a virtual environment using anaconda. Something like
conda create -n py352 python=3.5.2 anaconda
and then fire IDLE from your terminal. Though I am not entirely sure, if this works for mac. If it doesn't, let me know the output of -
import sys
print('\n'.join(sys.path))

Categories