rdegges / python-ipify

The official client library for ipify: A Simple IP Address API.
The Unlicense
133 stars 34 forks source link

on macOS, getting "ImportError: cannot import name 'linux_distribution' from 'platform' error #12

Open buckleyc opened 2 years ago

buckleyc commented 2 years ago

Trying to use latest ipify-1.0.0 with python 3.10.2 on macOS 11.6.5. Returns "ImportError: cannot import name 'linux_distribution' from 'platform'"

╭─[zephyr] as buckley in ~ using node v17.8.0   
╰──➤  python3 -m pip install --upgrade ipify
Collecting ipify
  Using cached ipify-1.0.0-py2.py3-none-any.whl (8.9 kB)
Requirement already satisfied: requests>=2.7.0 in ./.pyenv/versions/3.10.2/lib/python3.10/site-packages (from ipify) (2.27.1)
Collecting backoff>=1.0.7
  Using cached backoff-1.11.1-py2.py3-none-any.whl (13 kB)
Requirement already satisfied: urllib3<1.27,>=1.21.1 in ./.pyenv/versions/3.10.2/lib/python3.10/site-packages (from requests>=2.7.0->ipify) (1.26.8)
Requirement already satisfied: idna<4,>=2.5 in ./.pyenv/versions/3.10.2/lib/python3.10/site-packages (from requests>=2.7.0->ipify) (3.3)
Requirement already satisfied: certifi>=2017.4.17 in ./.pyenv/versions/3.10.2/lib/python3.10/site-packages (from requests>=2.7.0->ipify) (2021.10.8)
Requirement already satisfied: charset-normalizer~=2.0.0 in ./.pyenv/versions/3.10.2/lib/python3.10/site-packages (from requests>=2.7.0->ipify) (2.0.12)
Installing collected packages: backoff, ipify
Successfully installed backoff-1.11.1 ipify-1.0.0

╭─[zephyr] as buckley in ~ using node v17.8.0  
╰──➤  python3                               
Python 3.10.2 (main, Mar 10 2022, 20:48:21) [Clang 13.0.0 (clang-1300.0.29.30)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from ipify import get_ip
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/buckley/.pyenv/versions/3.10.2/lib/python3.10/site-packages/ipify/__init__.py", line 31, in <module>
    from .ipify import get_ip
  File "/Users/buckley/.pyenv/versions/3.10.2/lib/python3.10/site-packages/ipify/ipify.py", line 14, in <module>
    from .settings import API_URI, MAX_TRIES, USER_AGENT
  File "/Users/buckley/.pyenv/versions/3.10.2/lib/python3.10/site-packages/ipify/settings.py", line 9, in <module>
    from platform import mac_ver, win32_ver, linux_distribution, system
ImportError: cannot import name 'linux_distribution' from 'platform' (/Users/buckley/.pyenv/versions/3.10.2/lib/python3.10/platform.py)
>>> 
patrickswelsh commented 2 years ago

Try using an older version of Python. I'm seeing the same thing with python 3.9, but when I switched to 3.7 the errors went away... maybe use a virtual environment?

nicoteiza commented 1 year ago

I'm seeing the same with python 3.8 and 3.9

buckleyc commented 1 year ago

I have recently been running python 3.10.6, and went to check this issue; this is still persisting.

╭─[zephyr] as buckley in ~ using node v18.9.0                                                                                                                                   19:48:07 
╰──➤  /usr/local/bin/python3 -m pip install ipify                                                                     
Collecting ipify
  Using cached ipify-1.0.0-py2.py3-none-any.whl (8.9 kB)
Collecting backoff>=1.0.7
  Using cached backoff-2.1.2-py3-none-any.whl (14 kB)
Requirement already satisfied: requests>=2.7.0 in /usr/local/lib/python3.10/site-packages (from ipify) (2.28.1)
Requirement already satisfied: certifi>=2017.4.17 in /usr/local/lib/python3.10/site-packages (from requests>=2.7.0->ipify) (2022.6.15)
Requirement already satisfied: urllib3<1.27,>=1.21.1 in /usr/local/lib/python3.10/site-packages (from requests>=2.7.0->ipify) (1.26.10)
Requirement already satisfied: idna<4,>=2.5 in /usr/local/lib/python3.10/site-packages (from requests>=2.7.0->ipify) (3.3)
Requirement already satisfied: charset-normalizer<3,>=2 in /usr/local/lib/python3.10/site-packages (from requests>=2.7.0->ipify) (2.1.0)
Installing collected packages: backoff, ipify
Successfully installed backoff-2.1.2 ipify-1.0.0

╭─[zephyr] as buckley in ~ using node v18.9.0                                                                                                                                   19:48:40 
╰──➤  /usr/local/bin/python3                     
Python 3.10.6 (main, Aug 30 2022, 05:12:36) [Clang 13.1.6 (clang-1316.0.21.2.5)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from ipify import get_ip
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.10/site-packages/ipify/__init__.py", line 31, in <module>
    from .ipify import get_ip
  File "/usr/local/lib/python3.10/site-packages/ipify/ipify.py", line 14, in <module>
    from .settings import API_URI, MAX_TRIES, USER_AGENT
  File "/usr/local/lib/python3.10/site-packages/ipify/settings.py", line 9, in <module>
    from platform import mac_ver, win32_ver, linux_distribution, system
ImportError: cannot import name 'linux_distribution' from 'platform' (/usr/local/Cellar/python@3.10/3.10.6_2/Frameworks/Python.framework/Versions/3.10/lib/python3.10/platform.py)
>>> 
SigireddyBalasai commented 1 year ago

you need to use less than 3.5 for using but a new pull request will solve it all (Platform.linux_distribution ) is depricated in python 3.5