I am unable to run cdktf because cdktf won't work with packages installed from PyPI. I need cdktf to be able to install / access packages installed from PyPI.
$ cdktf diff
⠏ Synthesizing
[2022-11-11T14:03:01.343] [ERROR] default - Traceback (most recent call last):
File "/Users/jcbcodes/workspace/project/main.py", line 25, in <module>
from utils.foo import bar
File "/Users/jcbcodes/workspace/project/utils/foo.py", line 5, in <module>
import boto3
ERROR: cdktf encountered an error while synthesizing
Synth command: pipenv run python main.py
Error: non-zero exit code 1
Command output on stderr:
Traceback (most recent call last):
File "/Users/jcbcodes/workspace/project/main.py", line 25, in <module>
from utils.foo import bar
File "/Users/jcbcodes/workspace/project/utils/foo.py", line 5, in <module>
import boto3
ModuleNotFoundError: No module named 'boto3'
⠹ Synthesizing
boto3 is installed in my python virtual env. I also added boto3 to the Pipfile. I am unclear how to install packages listed under [packages]
in the Pipfile.
My Pipfile contains the following
[[source]]
name = "pypi"
url = "https://pypi.org/simple"
verify_ssl = true
[requires]
python_version = "3"
[packages]
cdktf = "~=0.13.3"
pytest = "*"
boto3 = "1.26.6"
As you have a Pipfile I'd expect your app command in your cdktf.json looks something like this:
pipenv run python main.py
. As you can see python is executed through Pipenv. You can usepipenv install
to install the dependencies and then use it as you normally would in your python program.