"ImportError: no suitable image found" using BeautifulSoup and Python3.8

Viewed 405

I am using BeautifulSoup and Python3.8 and all of a sudden, I am getting the following error. All the codes of BeautifulSoup have the same issue which worked till yesterday. I did not update anything.

The full error log is shown below:

/Users/me/PycharmProjects/bankOfAmeri/venv/bin/python /Users/me/PycharmProjects/myfewsteps/onlyTitles.py
Traceback (most recent call last):
  File "/Users/me/PycharmProjects/myfewsteps/onlyTitles.py", line 1, in <module>
    import requests
  File "/Users/me/PycharmProjects/myfewsteps/venv/lib/python3.8/site-packages/requests/__init__.py", line 43, in <module>
    import urllib3
  File "/Users/me/PycharmProjects/myfewsteps/venv/lib/python3.8/site-packages/urllib3/__init__.py", line 7, in <module>
    from .connectionpool import HTTPConnectionPool, HTTPSConnectionPool, connection_from_url
  File "/Users/me/PycharmProjects/myfewsteps/venv/lib/python3.8/site-packages/urllib3/connectionpool.py", line 7, in <module>
    from socket import error as SocketError, timeout as SocketTimeout
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/socket.py", line 52, in <module>
    import os, sys, io, selectors
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/selectors.py", line 11, in <module>
    import math
ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/lib-dynload/math.cpython-38-darwin.so, 2): no suitable image found.  Did find:
    /Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/lib-dynload/math.cpython-38-darwin.so: code signature in (/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/lib-dynload/math.cpython-38-darwin.so) not valid for use in process using Library Validation: Library load disallowed by System Policy

Process finished with exit code 1

Any solution to share which I can apply and resolve.

1 Answers

At the bottom line it states that you have restrictions on your system policy.

  • If you changed any settings within your environment then this is the most likely reason you are receiving and error.
  • I would also suggest if you have not already, using an installer to try and uninstall/reinstall requests.
  • Finally, you mentioned you did not update python. Although it's unlikely this could be the problem. Try updating python and see if that works. If updating python does not work, it's always good to be up to date anyway.

Hope this helped :)

Related