Error With IPAddresses Trying to use Boto3 on Ubuntu on AWS EC2
AttributeError: module ‘ipaddress’ has no attribute ‘IPv4Address’. Did you mean: ‘IPAddress’?
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
⚙️ Check out my series on Automating Cybersecurity Metrics | Code.
🔒 Related Stories: Bugs | AWS Security | Secure Code | Ubuntu | EC2
💻 Free Content on Jobs in Cybersecurity | ✉️ Sign up for the Email List
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
UGGGH. What is this.
apt-get install python3-pip
sudo pip install boto3
import boto3 in a py file.
![](https://cdn-images-1.readmedium.com/v2/resize:fit:800/1*S82ACgrfab8OtzfYAdaf5g.png)
I need to get the program to use this file specifically:
/usr/lib/python3.10/ipaddress.py
Seems to be using a file from some other source.
Now I’m sure this is *NOT* the way you probably should solve this problem but I’m in a hurry. I copied that file into the local directory with the rest of my python files and it works.
Traceback (most recent call last):
File “/….”, line 2, in <module>
import boto3
File “/home/ubuntu/.local/lib/python3.10/site-packages/boto3/__init__.py”, line 17, in <module>
from boto3.session import Session
File “/home/ubuntu/.local/lib/python3.10/site-packages/boto3/session.py”, line 17, in <module>
import botocore.session
File “/home/ubuntu/.local/lib/python3.10/site-packages/botocore/session.py”, line 26, in <module>
import botocore.client
File “/home/ubuntu/.local/lib/python3.10/site-packages/botocore/client.py”, line 15, in <module>
from botocore import waiter, xform_name
File “/home/ubuntu/.local/lib/python3.10/site-packages/botocore/waiter.py”, line 18, in <module>
from botocore.docs.docstring import WaiterDocstring
File “/home/ubuntu/.local/lib/python3.10/site-packages/botocore/docs/__init__.py”, line 15, in <module>
from botocore.docs.service import ServiceDocumenter
File “/home/ubuntu/.local/lib/python3.10/site-packages/botocore/docs/service.py”, line 14, in <module>
from botocore.docs.client import ClientDocumenter, ClientExceptionsDocumenter
File “/home/ubuntu/.local/lib/python3.10/site-packages/botocore/docs/client.py”, line 17, in <module>
from botocore.docs.example import ResponseExampleDocumenter
File “/home/ubuntu/.local/lib/python3.10/site-packages/botocore/docs/example.py”, line 13, in <module>
from botocore.docs.shape import ShapeDocumenter
File “/home/ubuntu/.local/lib/python3.10/site-packages/botocore/docs/shape.py”, line 19, in <module>
from botocore.utils import is_json_value_header
File “/home/ubuntu/.local/lib/python3.10/site-packages/botocore/utils.py”, line 37, in <module>
import botocore.httpsession
File “/home/ubuntu/.local/lib/python3.10/site-packages/botocore/httpsession.py”, line 45, in <module>
from urllib3.contrib.pyopenssl import (
File “/usr/lib/python3/dist-packages/urllib3/contrib/pyopenssl.py”, line 50, in <module>
import OpenSSL.SSL
File “/usr/lib/python3/dist-packages/OpenSSL/__init__.py”, line 8, in <module>
from OpenSSL import crypto, SSL
File “/usr/lib/python3/dist-packages/OpenSSL/crypto.py”, line 14, in <module>
from cryptography import utils, x509
File “/usr/lib/python3/dist-packages/cryptography/x509/__init__.py”, line 7, in <module>
from cryptography.x509.base import (
File “/usr/lib/python3/dist-packages/cryptography/x509/base.py”, line 22, in <module>
from cryptography.x509.extensions import Extension, ExtensionType, Extensions
File “/usr/lib/python3/dist-packages/cryptography/x509/extensions.py”, line 26, in <module>
from cryptography.x509.general_name import GeneralName, IPAddress, OtherName
File “/usr/lib/python3/dist-packages/cryptography/x509/general_name.py”, line 219, in <module>
class IPAddress(GeneralName):
File “/usr/lib/python3/dist-packages/cryptography/x509/general_name.py”, line 223, in IPAddress
ipaddress.IPv4Address,
AttributeError: module ‘ipaddress’ has no attribute ‘IPv4Address’. Did you mean: ‘IPAddress’?
Note that this problem magically fixed itself when I logged in the next day.
Follow for updates.
Teri Radichel | © 2nd Sight Lab 2023
About Teri Radichel:
~~~~~~~~~~~~~~~~~~~~
⭐️ Author: Cybersecurity Books
⭐️ Presentations: Presentations by Teri Radichel
⭐️ Recognition: SANS Award, AWS Security Hero, IANS Faculty
⭐️ Certifications: SANS ~ GSE 240
⭐️ Education: BA Business, Master of Software Engineering, Master of Infosec
⭐️ Company: Penetration Tests, Assessments, Phone Consulting ~ 2nd Sight Lab
Need Help With Cybersecurity, Cloud, or Application Security?
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
🔒 Request a penetration test or security assessment
🔒 Schedule a consulting call
🔒 Cybersecurity Speaker for Presentation
Follow for more stories like this:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
❤️ Sign Up my Medium Email List
❤️ Twitter: @teriradichel
❤️ LinkedIn: https://www.linkedin.com/in/teriradichel
❤️ Mastodon: @teriradichel@infosec.exchange
❤️ Facebook: 2nd Sight Lab
❤️ YouTube: @2ndsightlab
![](https://cdn-images-1.readmedium.com/v2/resize:fit:800/1*4oxP4LXk8l8c3mpRvO7ejg.png)