aws-samples / aws2tf

aws2tf - automates the importing of existing AWS resources into Terraform and outputs the Terraform HCL code.
MIT No Attribution
576 stars 102 forks source link

Cannot install python module stacks #85

Open schwinbp opened 3 months ago

schwinbp commented 3 months ago

Tried running the python version but got pummeled with missing modules that were never mentioned in readme. One module called Stacks failed to install. Any ideas how to install this?

pip install stacks Defaulting to user installation because normal site-packages is not writeable Collecting stacks Using cached stacks-0.1.0.tar.gz (39 kB) Preparing metadata (setup.py) ... error error: subprocess-exited-with-error

× python setup.py egg_info did not run successfully. │ exit code: 1 ╰─> [7 lines of output] Traceback (most recent call last): File "", line 2, in File "", line 34, in File "/tmp/pip-install-lh07je8o/stacks_1f362ba1bf024bdbb6d4471a93bf611b/setup.py", line 5 print "You need to install the setuptools module to install this software" ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)? [end of output]

note: This error originates from a subprocess, and is likely not a problem with pip. error: metadata-generation-failed

× Encountered error while generating package metadata. ╰─> See above for output.

note: This is an issue with the package mentioned above, not pip. hint: See above for details.

awsandy commented 3 months ago

Which operating system are you using ?

If you run:

python --version

are you running python v3 or v2 ?

I quite like: https://github.com/pyenv/pyenv

to get control, over my python versions/environments.

schwinbp commented 2 months ago

SOrry I forgot to add that info before.

OS: Ubuntu 22.04.4 LTS on WSL2 ((GNU/Linux 5.15.153.1-microsoft-standard-WSL2 x86_64))

Python3 --version => 3.10.12 python --version =>Command 'python' not found

awsandy commented 2 months ago

I've never tested this on the WSL2 (Windows Subsystem for Linux)

Perhaps look at the windws/WSL notes for pyenv - and try using it?

pyenv

PMiBu commented 1 day ago

i seem to have encountered the same issue

OS: Rocky Linux 9.4 (Blue Onyx) Kernel: Linux 5.14.0-427.40.1.el9_4.x86_64 Python: 3.9.18

awsandy commented 23 hours ago

Hi I just spun up a Rocky Linux 9.4 instance on AWS EC2 - and ran these commands below and then aws2tf without issues

So it must I think be related to your local python environment ? Perhaps try https://github.com/pyenv/pyenv


more /etc/os-release NAME="Rocky Linux" VERSION="9.4 (Blue Onyx)" ID="rocky" ID_LIKE="rhel centos fedora" VERSION_ID="9.4" PLATFORM_ID="platform:el9" PRETTY_NAME="Rocky Linux 9.4 (Blue Onyx)" .....

After EC2 starts:

sudo yum install unzip curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip” unzip awscliv2.zip sudo ./aws/install aws configure set region eu-west-1 sudo yum-config-manager --add-repo https://rpm.releases.hashicorp.com/RHEL/hashicorp.repo sudo yum -y install terraform sudo yum install git git clone https://github.com/aws-samples/aws2tf.git cd aws2tf python -m ensurepip —upgrade pip3 install -r requirements.txt

./aws2tf.py -t vpc aws2tf started at 2024-10-22 11:29:41.840115 region set from aws cli / environment variables as eu-west-1 Using region: eu-west-1 account: xxxxxxxxxxxx

terraform init Initializing the backend... . .....

Final Terraform Validation PASSED: Valid Configuration. Terraform import via apply of tfplan....

Post Import Plan Check ..... PASSED: No changes in plan trivy not installed, skipping security check Terraform files & state in sub-directory: generated/tf-xxxxxxxxxxxx-eu-west-1 aws2tf finished at 2024-10-22 11:30:58.21080

PMiBu commented 21 hours ago

i have tried using pyenv on my remote machine and switchted to python 3.10.15 and the error still occured. i had to install python-stacks to resolve this issue.