Qiita Teams that are logged in
You are not logged in to any team

Log in to Qiita Team
Community
OrganizationAdvent CalendarQiitadon (β)
Service
Qiita JobsQiita ZineQiita Blog
Help us understand the problem. What is going on with this article?

Anaconda Promptを使わずにPythonコマンドを実行する場合のエラー

はじめに

掲題のエラーについて対応した時のチップス。

環境

  • Windows10
  • Anaconda
  • Python3.7

現象

Anaconda でconda activate 等をせずにDOSプロンプト上で直接 Anacondaの仮想環境のptyhonを実行した場合に以下のエラーが発生した。

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "common/utils/create_project_schema.py", line 5, in <module>
    import numpy as np
  File "c:\ProgramData\Anaconda3\envs\hogehoge\lib\site-packages\numpy\__init__.py", line 142, in <module>
    from . import core
  File "c:\ProgramData\Anaconda3\envs\hogehoge\lib\site-packages\numpy\core\__init__.py", line 50, in <module>
    raise ImportError(msg)
ImportError:

IMPORTANT: PLEASE READ THIS FOR ADVICE ON HOW TO SOLVE THIS ISSUE!

Importing the numpy C-extensions failed. This error can happen for
many reasons, often due to issues with your setup or how NumPy was
installed.

We have compiled some common reasons and troubleshooting tips at:

    https://numpy.org/devdocs/user/troubleshooting-importerror.html

Please note and check the following:

  * The Python version is: Python3.7 from "c:\ProgramData\Anaconda3\envs\hogehoge\python.exe"
  * The NumPy version is: "1.18.5"

and make sure that they are the versions you expect.
Please carefully study the documentation linked above for further help.

Original error was: DLL load failed: 指定されたモジュールが見つかりません。

原因と対応

AnacondaプロンプトとMS DOSプロンプトの環境変数PATHの違いをよーくみてみると原因は、以下パスの不足だった。

C:\ProgramData\Anaconda3\envs\<仮想環境名>\Library\bin

上をシステム環境変数に設定することで解決。Python3.6では発生しなかったり、Anacondaのインストールの仕方によって変わってくる可能性はあるが、ご参考まで。

kimisyo
主にライフサイエンス分野向けサービス開発を行っています。これからはライフサイエンスの時代です。化学、AI(機械学習)を中心に、学んだこと、経験したことをシェアしていきます。
https://github.com/kimisyo
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away