I just installed html5lib for Python with Windows Command Prompt. The package was installed here:
File "C:\Python27\lib\site-packages\html5lib
However, if I try to import html5lib:
#! /usr/bin/python
import html5lib
I get the following error:
Traceback (most recent call last):
File "C:\Users\workspace\testhtml5\src\test.py", line 2, in <module>
import html5lib
File "C:\Python27\lib\site-packages\html5lib\__init__.py", line 16, in <module>
from .html5parser import HTMLParser, parse, parseFragment
File "C:\Python27\lib\site-packages\html5lib\html5parser.py", line 2, in <module>
from six import with_metaclass
ImportError: No module named six
Any idea on what might be causing the error? Thanks
You're missing the six module. You can download it from here, or better, use pip install six .
Related
My issue
i have downloaded chardet, requests, typing, binary io, and django modules in an effort to fix whatever issue i am having while importing python module requests.
I also reainstalled python with the standard group of python modules option. I dont know what the issue is please help. Thank you.
Further information
Python 3.9
Installed using pip
The code:
import requests
Below is the error log:
Traceback (most recent call last):
File "C:\PROGRA~1\IBM\SPSS\STATIS~1\26\Python3\Lib\site-packages\requests\compat.py", line 12, in <module>
import chardet
ImportError: No module named 'chardet'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<pyshell#0>", line 1, in <module>
import requests
File "C:\PROGRA~1\IBM\SPSS\STATIS~1\26\Python3\Lib\site-packages\requests\__init__.py", line 45, in <module>
from .exceptions import RequestsDependencyWarning
File "C:\PROGRA~1\IBM\SPSS\STATIS~1\26\Python3\Lib\site-packages\requests\exceptions.py", line 11, in <module>
from .compat import JSONDecodeError as CompatJSONDecodeError
File "C:\PROGRA~1\IBM\SPSS\STATIS~1\26\Python3\Lib\site-packages\requests\compat.py", line 14, in <module>
import charset_normalizer as chardet
File "C:\PROGRA~1\IBM\SPSS\STATIS~1\26\Python3\Lib\site-packages\charset_normalizer\__init__.py", line 24, in <module>
from .api import from_bytes, from_fp, from_path, normalize
File "C:\PROGRA~1\IBM\SPSS\STATIS~1\26\Python3\Lib\site-packages\charset_normalizer\api.py", line 3, in <module>
from typing import BinaryIO, List, Optional, Set
ImportError: No module named 'typing'
I have found the issue after checking everything using pip. All modules up to date python up to date pip up to date. However despite completely uninstalling and reinstalling setuptools was out of date. so i updated setuptools with pip.
to find out whats out of date with pip:
pip list --outdated
One of my script is importing Investpy library and I encoutered the following error message when I have checked the site-package the Investpy is in place.
Traceback (most recent call last):
File "/Users/LSH/WSFG_DEV/workspace/telegram_bot/roe_eps_check.py", line 9, in <module>
import investpy
File "/Users/LSH/Library/Python/3.8/lib/python/site-packages/investpy/__init__.py", line 7, in <module>
from .stocks import get_stocks, get_stocks_list, get_stocks_dict, get_stock_countries, get_stock_recent_data, \
File "/Users/LSH/Library/Python/3.8/lib/python/site-packages/investpy/stocks.py", line 16, in <module>
from lxml.html import fromstring
File "/Users/LSH/Library/Python/3.8/lib/python/site-packages/lxml/html/__init__.py", line 53, in <module>
from .. import etree
ImportError: cannot import name 'etree' from 'lxml' (/Users/LSH/Library/Python/3.8/lib/python/site-packages/lxml/__init__.py)
LSH#LSHs-Air workspace %
Does anyone know what is wrong? I have already remove and re-install Investpy but no luck.
Thank you everyone!! :)
You could try and do:
pip install lxml-4.6.3-cp38-cp38-win_amd64
OR
python -m pip install lxml==3.6.0
If this doesn't fix the issue, uninstall lxml and reinstall it using pip
Source:
ImportError: cannot import name 'etree' on Python 3.6
I am trying to run a program (obviously written in python) and it requires some python modules. One of the missed modules is aiomultiprocess. I tried installing it with pip install aiomultiprocess pip3 install aiomultiprocess python3.7 -m pip install aiomultiprocess but they all come back with the same error message:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/usr/local/lib/python3.7/site-packages/setuptools/__init__.py", line 19, in <module>
from setuptools.dist import Distribution
File "/usr/local/lib/python3.7/site-packages/setuptools/dist.py", line 34, in <module>
from setuptools import windows_support
File "/usr/local/lib/python3.7/site-packages/setuptools/windows_support.py", line 2, in <module>
import ctypes
File "/usr/local/lib/python3.7/ctypes/__init__.py", line 10, in <module>
from _ctypes import Union, Structure, Array
File "/usr/local/lib/python3.7/_ctypes.py", line 5, in <module>
import ffi
ModuleNotFoundError: No module named 'ffi'
No ffi module?! Let's get it!
I looked it up and figured it's a foreign library that come, in the case of python, as 2 forms: CFFI & LibFFI, but "ffi" doesn't exist for python. I installed cffi libffi and added them to this path /usr/local/lib/python3.7/site-packages/, but it changed nothing.
So my question is there another way to install python modules without the need of pip??!
Here is my error:
Traceback (most recent call last):
File "./convert.py", line 6, in <module>
import openpyxl # from https://pythonhosted.org/openpyxl/ or PyPI (e.g. via pip)
ImportError: No module named openpyxl
i have installed the python package openpyxl but this error still appear
Im using linux python version 2.6.6
any help please
i got this new error when i ran the python2.7 script.py:
Traceback (most recent call last):
File "/usr/local/bin/pip", line 7, in <module>
from pip import main
File "/usr/local/lib/python2.7/site-packages/pip/__init__.py", line 13, in <module>
from pip.utils import get_installed_distributions, get_prog
File "/usr/local/lib/python2.7/site-packages/pip/utils/__init__.py", line 15, in <module>
import zipfile
File "/usr/local/lib/python2.7/zipfile.py", line 6, in <module>
import io
File "/usr/local/lib/python2.7/io.py", line 51, in <module>
import _io
ImportError: /usr/local/lib/python2.7/lib-dynload/_io.so: undefined symbol: _PyErr_ReplaceException
openpyxl module has 2 dependent modules : 1. jdcal 2. et_xmlfile
I was able to install openpyxl module and this is what I did :
1.Downloaded the openpyxl,jdcal and et_xmlfile from https://pypi.python.org/pypi and saved jdcal-1.0.tar.gz, et_xmlfile-1.0.0.tar.gz,openpyxl-2.3.0-b2.tar.gz in a local folder in my system.
2.Then I ran the commands in the following order :
pip install jdcal-1.0.tar.gz
pip install et_xmlfile-1.0.0.tar.gz
pip install openpyxl-2.3.0-b2.tar.gz
openpyxl got successfully after this. Please check whether this helps.
I tried importing the pycrunchbase api wrapper and i get the following error.
It is a API wrapper that use the Crunchbase API platform
Doc: https://pycrunchbase.readthedocs.org/en/latest/usage.html
Github: https://github.com/ngzhian/pycrunchbase
>>> from pycrunchbase import *
Traceback (most recent call last):
File "<pyshell#2>", line 1, in <module>
from pycrunchbase import *
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pycrunchbase/__init__.py", line 1, in <module>
from .pycrunchbase import (
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pycrunchbase/pycrunchbase.py", line 4, in <module>
from .resource import (
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pycrunchbase/resource/__init__.py", line 1, in <module>
from .acquisition import Acquisition
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pycrunchbase/resource/acquisition.py", line 3, in <module>
from .node import Node
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pycrunchbase/resource/node.py", line 3, in <module>
from .relationship import NoneRelationshipSingleton, Relationship
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pycrunchbase/resource/relationship.py", line 3, in <module>
from .page import Page
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pycrunchbase/resource/page.py", line 4, in <module>
from .pageitem import PageItem
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pycrunchbase/resource/pageitem.py", line 58, in <module>
#six.python_2_unicode_compatible
AttributeError: 'module' object has no attribute 'python_2_unicode_compatible'
This is likely because your OS X is referencing an older version of six, that is not in your pip installed directory.
Pip installs in /Library/[..] while your system python installs in /System/Library/[..]
If you pip install six, it probably installs 1.9.0, but when you go into your python console, and type
>>> import six
>>> six.__version__
'1.4.1'
You'll probably get the above.
There's two options...the first and easiest is to just implement a virtualenv.
The second is to go to /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python and
$ rm six.py six.pyc
This will then force your console to reference your pip directory as opposed to your python dir, and the proper version will be referenced.
Hope that makes sense.
The pycrunchbase module has dependencies on the six and requests modules.
To get pycrunchbase working:
pip install requests six
And then you should be all set!