[PYTHON] In the Chainer tutorial, I get an error when importing a package. (mock)

Introduction to Chainer

After installing chainer, execute the following command in the tutorial to load the python package.

import numpy as np
import chainer
from chainer import cuda, Function, gradient_check, report, training, utils, Variable
from chainer import datasets, iterators, optimizers, serializers
from chainer import Link, Chain, ChainList
import chainer.functions as F
import chainer.links as L
from chainer.training import extensions

Then I get the following error:

>>> from chainer import cuda, Function, gradient_check, report, training, utils, Variable
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/hiroyasu/.pyenv/versions/anaconda3-4.2.0/lib/python3.5/site-packages/chainer/gradient_check.py", line 9, in <module>
    from chainer import testing
  File "/Users/hiroyasu/.pyenv/versions/anaconda3-4.2.0/lib/python3.5/site-packages/chainer/testing/__init__.py", line 7, in <module>
    from chainer.testing import training  # NOQA
  File "/Users/hiroyasu/.pyenv/versions/anaconda3-4.2.0/lib/python3.5/site-packages/chainer/testing/training.py", line 1, in <module>
    import mock
ImportError: No module named 'mock'

I installed chainer, but it seems that there was no package called mock.

After downloading the mock from pip, the error disappeared.

pip install

Recommended Posts

In the Chainer tutorial, I get an error when importing a package. (mock)
When I get a chromedriver error in Selenium
I get an error when I put opencv in pyautoGUI
I get an error when I put a Python plugin in Visual Studio Code under the pyenv environment
When I get an error with Pylint in Atom on Windows
When I get an error with PyInstaller
[Python] I want to know the variables in the function when an error occurs!
When I name the file flask.py in Flask, I get Import Error: cannot import name'Flask'
I get a strange window when I use the open directory dialog in Tkinter
I get a java.util.regex.PatternSyntaxException when splitting a string in PySpark
I get an Import Error in Python Beautiful Soup
I get an error when trying meinheld + WebSocket + mongodb
When you get an error in python scraping (requests)
What to do if you get an error when importing matplotlib in Python (Mac)
When I run pipenv install <package name>, I get a "No matching distribution found for <package name>" error.
Check the argument type annotation when executing a function in Python and make an error
I get a UnicodeDecodeError in mecab-python3
I get a KeyError in pyclustering.xmeans
I got an AttributeError when mocking the open method in python
I get an error when trying to install maec 4.0.1.0 with pip
I get a can't set attribute when using @property in python
Get the formula in an excel file as a string in Python
I got an error when I tried to process luigi in parallel on windows, but the solution
I got an SSL Error when I installed Anaconda in a new environment, so I solved it (Windows10, Anaconda3-2019.10)
I get an OS Error: [Errno 8] Exec format error when running a Flask application with a python command
I get an error with import pandas.
Get the longest character length contained in an interval in a segment tree
An error that does not work as expected when calling the tkinter module in a text editor
I can't get the element in Selenium!
I get a Python No module named'encodings' error with the aws command
Install the package in an offline environment
If you get a no attribute error in boto3, check the version
What to do if you get an error when trying to send a message in tasks.loop () immediately after startup
I get an error ~ is zero, singular U when passing the covariance matrix from the Linear layer to MultivariateNormal
I got an error when trying to run Hello World in Go language
I got an error when I put opencv in python3 with Raspberry Pi [Remedy]
I made an appdo command to execute a command in the context of the app
[Python] What to check when you get a Unicode Decode Error in Django
If you get a long error when tabbing an interactive shell with Anaconda
Create a filter to get an Access Token in the Graph API (Flask)
I referred to it when I got stuck in the django geodjango tutorial (editing)
I got an error when saving with OpenCV
[Python] Get the files in a folder with Python
Get the caller of a function in Python
Install the python package in an offline environment
Get only the subclass elements in a list
I get a UnicodeDecodeError when running with mod_wsgi
I get an error with all yum commands
An error occurs when importing japandas (problem unsolved)
I get an error when installing scipy on t2.micro because I don't have enough memory
When I try to import pandas on macOS I get the error No module named'_bz2'
A story that an error occurred when PyInstaller was used in a program that uses googleapiclient
I want to get an error message in Japanese with django Password Change Form
What to do if you get an Import Error when importing matplotlib with Jupyter
I get an error when I try to raise Python to 3 series using pyenv on Catalina
Get the file name in a folder using glob
What I did when I stumbled on a Django tutorial
BigQuery-If you get a Reason: responseTooLarge error in Python
I want to write in Python! (3) Utilize the mock
A memorandum when an error occurs with pip install
I got an error when using Tensorboard with Pytorch