Tag Archives: No module named XXX error

Python ImportError: No module named win32com.client [How to Solve]

Error in Python: importerror: no module named win32com.client

[questions]

[solved] processing operation in Python chart in Excel

Use the code:

#!/usr/bin/python
# -*- coding: utf-8 -*-
"""
Function:
[Solved] Handling charts in Excel in Python (Chart, Graph)

【已解决】Python中处理操作Excel中的图表(Chart,Graph)
Author: Crifan Li Version: 2012-12-25 Contact: admin at crifan dot com """ from win32com.client import Dispatch; def excelChart(): ex = Dispatch("Excel.Application"); print "ex=",ex; if __name__ == "__main__": excelChart();

The result runs with the error.

D:\tmp\tmp_dev_root\python\excel_chart>excel_chart.py

Traceback (most recent call last):

File “D:\tmp\tmp_dev_root\python\excel_chart\excel_chart.py”, line 13, in <module>

from win32com.client import Dispatch;

ImportError: No module named win32com.client

[Solution Process

1. Reference.

http://sourceforge.net/projects/pywin32/

Find

http://sourceforge.net/projects/pywin32/files/pywin32/

in the latest

http://sourceforge.net/projects/pywin32/files/pywin32/Build%20218/

Then go and download the corresponding version.

Here I have Win7 64-bit + Python 2.7.3

So it is.

pywin32-218.win-amd64-py2.7.exe

2. After downloading, get pywin32-218.win-amd64-py2.7.exe and go to install: pywin32-218.win-amd64-py2.7.exe.

3. After installation, go try the code again and it will be normal:.

D:\tmp\tmp_dev_root\python\excel_chart>excel_chart.py

ex= Microsoft Excel

[Summary]

Win32com.client corresponds to the library Pywin32, which is installed and ready to use.

No module named ‘sklearn.model_selection [How to Solve]

Run and import the following modules in Python

from sklearn.model_selection import train_test_split

An error occurred:

No module named ‘sklearn.model_ selection

Run Anaconda prompt, input CONDA list to view the versions of various libraries, and find that

Model is not included in version 0.17.1_ Select library, run the following command to update the library

View the version of the library when the update is complete

Run at the beginning of the code, no error, problem solving

Pycharm ImportError: No module named selenium [How to Solve]

After using PIP install to successfully install a module, a similar error is prompted when importing and using it in pycharm

ImportError: No module named selenium

The original meaning of this error may be that you have installed more than one python, but the python configuration path of pycharm is not correct. For example, if selenium is downloaded to python3 and pychar’s Python configuration path is python2.7, this error will appear

Modify pycharm configuration path as follows:

Select preference and look at the picture

After selecting the correct version, the import will no longer prompt similar errors

ModuleNotFoundError: No module named ‘PyQt4’ [Spyder Import matplotlib Error]

I just learned Matplotlib recently, and I want to play in Anaconda’s Spyder

The code is as follows (in fact, it’s not important, mainly because matplotlib.pyplot is imported and an error is reported)

# -*- coding: utf-8 -*-
"""
Created on Thu Jul 12 21:36:51 2018

@author: asus
"""
print("b")

import matplotlib.pyplot as plt
print("a")

a= [1,2,3]
b= [1,2,3]

plt.plot(a,b)
plt.show()

error message:

File "C:\Users\asus\Anaconda3\lib\site-packages\matplotlib\backends\qt_compat.py", line 157, in <module>
    from PyQt4 import QtCore, QtGui

ModuleNotFoundError: No module named 'PyQt4'

The problem is QT_ Compat.py file

The error indicates that PyQt4 can’t be found. The direct solution is to install PyQt4 package. However, after several times (taking two or three days) of various data searching and various attempts, all failed

The basic contradiction is that pyqt5 is configured by default in Anaconda environment, while PyQt4 is called by default in Matplotlib, which is a version problem

Finally, back to QT_ Compat.py file

if rcParams['backend'] == 'Qt5Agg':
    QT_RC_MAJOR_VERSION = 5
elif rcParams['backend'] == 'Qt4Agg':
    QT_RC_MAJOR_VERSION = 4

Notice the above code, try changing the default version


solutions

In QT_ Add code to compat.py file:

rcParams['backend']='Qt5Agg'

Namely:

""" A Qt API selector that can be used to switch between PyQt and PySide.
"""

from __future__ import (absolute_import, division, print_function,
                        unicode_literals)

import six

import os
import logging
import sys
from matplotlib import rcParams

#rcParams['backend']='PyQt5'    # added by chen to adapt the matplotlib
rcParams['backend']='Qt5Agg'    # added by chen to adapt the matplotlib
#print("----------------"+rcParams['backend'])

_log = logging.getLogger(__name__)

(ignore comment line)

Save, run the original file, success

No module named ‘pkg_resources.extern’ [How to Solve]

When reading “flame web development”, you need to install the virtual environment through virtualenv tools, and you need to use easy to find a tool_ Install to install. After operating according to the official tutorial setup tools, enter:
easy on the command line_ Install virtualenv gets the following output:

Traceback (most recent call last):
  File "D:\Python34\Scripts\easy_install-script.py", line 11, in <module>
    load_entry_point('setuptools==28.6.1', 'console_scripts', 'easy_install')()
  File "D:\Python34\lib\site-packages\pkg_resources\__init__.py", line 519, in load_entry_point
    return get_distribution(dist).load_entry_point(group, name)
  File "D:\Python34\lib\site-packages\pkg_resources\__init__.py", line 2630, in load_entry_point
    return ep.load()
  File "D:\Python34\lib\site-packages\pkg_resources\__init__.py", line 2310, in load
    return self.resolve()
  File "D:\Python34\lib\site-packages\pkg_resources\__init__.py", line 2316, in resolve
    module = __import__(self.module_name, fromlist=['__name__'], level=0)
  File "d:\python34\lib\site-packages\setuptools-28.6.1-py3.4.egg\setuptools\__init__.py", line 10, in <module>
  File "d:\python34\lib\site-packages\setuptools-28.6.1-py3.4.egg\setuptools\extern\__init__.py", line 1, in <module>
ImportError: No module named 'pkg_resources.extern'

To solve this problem, run the following command:

pip install --upgrade setuptools
pip install --upgrade distribute

Exception record-No module named ‘numpy.core._multiarray_umath

Problem Description:

Obviously installed numpy, and often used and no error occurred, but the following error occurred

No module named’numpy.core._multiarray_umath

 

Solution:

1. The model may not be saved successfully due to an error when saving the model, just delete the saved model at this time

2. numpy version is too low

Show version pip show numpy

Upgrade version pip install –upgrade numpy

 

Pycharm Error: ImportError: No module named model_selection

first of all, I want to explain that I have this problem because I need to use train_ test_ Split method, the specific reference is:

from sklearn.model_selection import train_test_split

this error occurred:

ImportError: No module named model_selection

I checked on the Internet and found out the cause of the problem. One thing Dashen gave me was that there was a problem with my sklearn version, which was train before version v0.18_ test_ Split is placed in cross_ In the validation module, now, there are two solutions to this problem:

Method 1.

will:

from sklearn.model_selection import train_test_split

TO:

from sklearn.cross_validation import train_test_split

 

Method 2.

Upgrade sklearn to v0.18 or above

If your pychar compilation environment is Anaconda’s python, enter
in the anaconda prompt operation line

The CONDA update scikit learn command updates the version of sklearn. Before updating, you will be prompted to what version to update

Or enter PIP install — upgrade scikit learn to update the version
as well

 

 

 

Python for mac or windows: ModuleNotFoundError: No module named ‘lxml’ [How to Solve]

error

Traceback (most recent call last):

File “reptile.py”, line 4, in <module>

from lxml import etree

ModuleNotFoundError: No module named ‘lxml’

jiaxiaobindeMacBook-Pro:exercise jss$ No module named ‘lxml’

-bash: No: command not found

Mac OS python

Under an existing pip

$STATIC_DEPS=true pip install lxml

refer:

https://stackoverflow.com/questions/22674730/importerror-no-module-named-lxml-on-mac

Caffe Install ImportError: No module named google.protobuf.internal

problem description

~/Downloads/caffe$ python
Python 2.7.12 (default, Dec  4 2017, 14:50:18)
[GCC 5.4.0 20160609] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import caffe
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/xxx/Downloads/caffe/python/caffe/__init__.py", line 1, in <module>
    from .pycaffe import Net, SGDSolver, NesterovSolver, AdaGradSolver, RMSPropSolver, AdaDeltaSolver, AdamSolver, NCCL, Timer
  File "/home/xxx/Downloads/caffe/python/caffe/pycaffe.py", line 15, in <module>
    import caffe.io
  File "/home/xxx/Downloads/caffe/python/caffe/io.py", line 8, in <module>
    from caffe.proto import caffe_pb2
  File "/home/xxx/Downloads/caffe/python/caffe/proto/caffe_pb2.py", line 6, in <module>
    from google.protobuf.internal import enum_type_wrapper
ImportError: No module named google.protobuf.internal

solutions

sudo pip install  easydict
sudo pip install protobuf