Error when executing Python commands without using Anaconda Prompt

Introduction

Chips when dealing with the error in the subject.

environment

phenomenon

The following error occurred when ptyhon of Anaconda's virtual environment was executed directly on the DOS prompt without performing conda activate etc. in Anaconda.

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:The specified module cannot be found.

Cause and response

Looking closely at the difference between the environment variable PATH of the Anaconda prompt and the MS DOS prompt, the cause was the following insufficient path.

C:\ProgramData\Anaconda3\envs\<Virtual environment name>\Library\bin

Solved by setting the above in the system environment variable. It may not occur in Python3.6, or it may change depending on how Anaconda is installed, but for your reference.

Recommended Posts

Error when executing Python commands without using Anaconda Prompt
[Python] Error and solution memo when using venv with pyenv + anaconda
Error due to conflict between python when using gurobi
Error when playing with python
[python] Error when installing library ramkan
How to install python using anaconda
Precautions when using pit in Python
Error when building mac python environment
[Python3] Google translate google translate without using api
# Solution when pip install gives an error when using Anaconda on Windows 10
Slice without using Python, colon (:). a.__getitem__ (slice (3,5)).
[Python] Be careful when using print
Error log output method when using Bottle framework on GAE / Python
Precautions when using phantomjs from python
When using MeCab with virtualenv python
Precautions when using six with Python 2.5
[VS Code] ~ Tips when using python ~
When using regular expressions in Python
Python3.6 environment construction (using Win environment Anaconda)
How to deal with OAuth2 error when using Google APIs from Python
Precautions and error handling when calling .NET DLL from python using pythonnet
Periodic execution processing when using tkinter [Python3]
Favicon placement (when using Python, Flask, Heroku)
[python, multiprocessing] Behavior for exceptions when using multiprocessing
Error, warning when using TensorFlow on Mac
When Python "Syntax Error: Non-ASCII character ~" appears
Error when installing a module with Python pip
Build Python3.5 + matplotlib environment on Ubuntu 12 using Anaconda
Character encoding when using csv module of python 2.7.3
Error when trying to install psycopg2 in Python
What are you using when testing with Python?
Investigate the cause when an error is thrown when python3.8 is not found when using lambda-uploader with python3.8
I get an error when I try to raise Python to 3 series using pyenv on Catalina