[Note] Anaconda & VScode has trouble with python import error

Introduction When I run python in the terminal, I get an error when importing the module. This time is the memorandum.

Environment mac:Big Sur Editor: VScode Python:3.8

Trouble content When I run a python file written in VScode in a terminal, I get angry because it's not such a module. But it's imported numpy, so it's not without it! !! If you just google for it Apparently, if the python used from the terminal and the python set in VScode are different, an import error will occur.

Solution At the terminal
pip show numpy

Type to see Location. In my case

anaconda3/lib/python3.8/site-packages

I was using python in anaconda3. However, specify / usr / bin / python3 with VScode I was doing it, so I got an error. It was easy if I knew it.

Later talk A few days after resolving this issue, I got the same error again. This time, I'm wondering if the python used is the same, so I just google it again. As a result, it seems that the module version was old. So
pip install -U numpy

It is solved by. You can use it for general purposes by changing numpy to the module name where the error occurs. By the way

pip list -o

Then, the old version will be displayed in a list.

Recommended Posts

[Note] Anaconda & VScode has trouble with python import error
Homebrew Vim doesn't start with Python 3.8 error Note
Use Python 3.8 with Anaconda
Import tsv with Python
Install Python environment with Anaconda
Import vtk with brew python
[Note] Operate MongoDB with Python
Error when playing with python
Import error resolution record when touching Python code from VSCode
Working with LibreOffice in Python: import
Debug python multiprocess program with VSCode
(Note) Be careful with python argparse
[Python] Error and solution memo when using venv with pyenv + anaconda
[Note] Hello world output with python
Python import directory order (on anaconda)
About import error of PyQt5.QtWidgets (Anaconda)
Dealing with Python error "Attribute Error: module'scipy.misc' has no attribute'imresize'" in deep learning
I get an error with import pandas.
[Python] Building an environment with Anaconda [Mac]
[Note] Get data from PostgreSQL with Python
Import error even though python is installed
Note when creating an environment with python
[Python] Create a virtual environment with Anaconda
[Personal note] Web page scraping with python3
windows7 / python3.3 / virtualenv / cx_Freeze / Import Error / MAXREPEAT
Trying to handle SQLite3 with Python [Note]
Build Python environment with Anaconda on Mac
Import Error in Python3: No module named'xxxxx'
Note: Python
Python note
[Note] The solution for Python on MacOSX where import hashlib causes an error
Python environment construction (Anaconda + VSCode) @ Windows10 [January 2020 version]
[Note] Export the html of the site with python.
Building an Anaconda environment for Python with pyenv
Building a Python environment with WLS2 + Anaconda + PyCharm
Let's write FizzBuzz with an error: Python Version
Install OpenCV 4.0 and Python 3.7 on Windows 10 with Anaconda
Python> Run with run-time arguments> Use import argparse
[Note] Create a one-line timezone class with python
Note for formatting numbers with python format function
Investigation when import cannot be done with python
Trouble with Python pseudo-private variables and class inheritance
[python] [vscode] When you get angry with space-tab-mixed
Download and import files with Splunk external python
Use Python in Anaconda environment with VS Code
From Python environment construction to virtual environment construction with anaconda
Python script to get note information with REAPER