Whenever I build a Python virtual environment for DynamoDb-Lambda in my local environment Since boto3 could not be imported, I would like to summarize the procedure with a memorandum.
--Create a virtual environment
$ python3 -m venv environment name
--Enable the created environment
$source The name of the environment/bin/activate
--When it is successfully enabled, the following display will be displayed.
(The name of the environment) $
--Install the required packages (boto3 in this case) By the way, I installed boto3 as it is without entering the environment, so boto3 will always be I was not on the virtual environment side. .. ..
$ pip install boto3
--Use the python -m pip list
command to check if the target package is installed properly.
$ python -m pip list
Package Version
--------------- -------
boto3 1.12.23
botocore 1.15.23
docutils 0.15.2
jmespath 0.9.5
numpy 1.18.2
pip 19.0.3
python-dateutil 2.8.1
s3transfer 0.3.3
setuptools 40.8.0
six 1.14.0
urllib3 1.25.8
It seems that this time it is well entered.
--Open the folder created this time --Open setting.json and add the following I made a mistake in the description here, but the path was peeled off to an environment other than the virtual environment side, and boto3 could not be imported ...
"python.pythonPath": "bin/python3",
-[Introduction to Python] An easy-to-understand explanation of how to create a virtual environment with venv -How to open VS Code settings.json
Recommended Posts