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

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.

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

Django site fails with "ImportError: cannot import name '_BACKCOMPAT_MAGIC_NUMBER'" after working fine for months

I have Django app on hosting which has been running since June last year. I forgot to buy credits and so my hosting provider freezed my app. I bought new credits but I does not start. I simply get: "502 Bad Gateway".
I checked the logs, and in python.log found possible problem. Here is the traceback:
Traceback (most recent call last):
File "/srv/venv/bin/gunicorn", line 7, in <module>
from gunicorn.app.wsgiapp import run
File "/srv/venv/lib/python3.5/site-packages/gunicorn/app/wsgiapp.py", line 10, in <module>
from gunicorn.app.base import Application
File "/srv/venv/lib/python3.5/site-packages/gunicorn/app/base.py", line 12, in <module>
from gunicorn import util
File "/srv/venv/lib/python3.5/site-packages/gunicorn/util.py", line 12, in <module>
import pkg_resources
File "/srv/venv/lib/python3.5/site-packages/pkg_resources/__init__.py", line 26, in <module>
import zipfile
File "/opt/python/lib/python3.5/zipfile.py", line 9, in <module>
import importlib.util
File "/srv/venv/lib/python3.5/importlib/util.py", line 7, in <module>
from ._bootstrap_external import MAGIC_NUMBER, _BACKCOMPAT_MAGIC_NUMBER
ImportError: cannot import name '_BACKCOMPAT_MAGIC_NUMBER'
As far as I know there weren't any changes prior to this problem. Moreover I cannot find similar issues here on SO or elsewhere on the net.
importlib should be part of Python 3 so I thought I could try commenting out the import from "/opt/python/lib/python3.5/zipfile.py" but I don't have write permissions on the server.
I also tried recreating the venv which did not help. Same with switching Python runtime to either 3.4 or 3.6 in hosting's administration.

What is a correct way to import "RPi.GPIO as GPIO" for use in a python thread?

I have a python program to which I am adding GPIO pin control functionality. It is a multi-threaded system that runs fine until I try to do an "import RPi.GPIO as GPIO". Then I get the error below:
Traceback (most recent call last):
File "/usr/local/System/main.py", line 20, in <module>
from LightUpAlarm import AlarmCli
File "/usr/local/System/LightUpAlarm/AlarmCli.py", line 26, in <module>
from AlarmManager import AlarmManager
ImportError: No module named AlarmManager
The module "AlarmManager" was available until I tried to import "RPi.GPIO". I would appreciate any help understanding what I am doing wrong. Thanks in advance.
Pastebin link to full python file generating error. AlarmThread.py

Python/Flask error: “ImportError: cannot import name _compare_digest”

I run linux mint 17.2 XCFE on my computer.
My issue is nearly identical to the one found in this thread, except I tried all of the solutions offered and none worked. It's worth noting that as a result of me trying to fiddle with python, my machine now runs 2.7.8 and the venv runs 2.7.6, which is easy to fix but might be relevant.
I also consulted this and this, and tried changing the name of file called operator and a different virtualenv command as suggested in those, but nothing worked. (Note: I then changed the name of that file back to operator just because since that wasn't the problem I'd rather not mess with it).
When I try to run a very simple script for flask newbs I keep encountering the same error.
(venv)joshua#joshua-ThinkPad-Edge-E430 ~/website/projects/helloapp $ python hello.py
Traceback (most recent call last):
File "hello.py", line 1, in <module>
from flask import Flask
File "/home/joshua/website/projects/helloapp/venv/lib/python2.7/site-packages/flask/__init__.py", line 21, in <module>
from .app import Flask, Request, Response
File "/home/joshua/website/projects/helloapp/venv/lib/python2.7/site-packages/flask/app.py", line 26, in <module>
from . import json
File "/home/joshua/website/projects/helloapp/venv/lib/python2.7/site-packages/flask/json.py", line 25, in <module>
from itsdangerous import json as _json
File "/home/joshua/website/projects/helloapp/venv/lib/python2.7/site-packages/itsdangerous.py", line 14, in <module>
import hmac
File "/home/joshua/anaconda/lib/python2.7/hmac.py", line 8, in <module>
from operator import _compare_digest as compare_digest
ImportError: cannot import name _compare_digest
I have been trying to figure out a solution on my own for hours but I've had no luck. I think it might have to do with Anaconda but I'm not sure what could be done if that's the case.
As it turns out the issue was that the hmac.py file had a reference to a method that it appears no longer existed. I disabled that reference with '#' (just incase it turns out it was important) and it started working.

Python requests_ntlm import error

Hello i am receiving the following error when i try to import the requests_ntlm package. I installed the package with easy_install requests-ntlm. I am trying to use this library so that I can log onto an aspx.net webserver with www-authenticate: negotatiate NTLM response header using python. Appreciate any help solving this issue let me know if I need to provide more information. Thanks!
Traceback (most recent call last):
File "SHS.py", line 2, in <module>
from requests_ntlm import HttpNtlmAuth
File "build\bdist.win-amd64\egg\requests_ntlm\__init__.py", line 1, in <module
>
File "build\bdist.win-amd64\egg\requests_ntlm\requests_ntlm.py", line 4, in <m
odule>
File "C:\python27\lib\site-packages\python_ntlm3-1.0.1-py2.7.egg\ntlm3\__init_
_.py", line 2, in <module>
from . import HTTPNtlmAuthHandler # noqa
File "C:\python27\lib\site-packages\python_ntlm3-1.0.1-py2.7.egg\ntlm3\HTTPNtl
mAuthHandler.py", line 20, in <module>
from . import ntlm
File "C:\python27\lib\site-packages\python_ntlm3-1.0.1-py2.7.egg\ntlm3\ntlm.py
", line 25, in <module>
from . import des
File "C:\python27\lib\site-packages\python_ntlm3-1.0.1-py2.7.egg\ntlm3\des.py"
, line 19, in <module>
from . import des_c
File "C:\python27\lib\site-packages\python_ntlm3-1.0.1-py2.7.egg\ntlm3\des_c.p
y", line 19, in <module>
from .des_data import des_SPtrans, des_skb
File "C:\python27\lib\site-packages\python_ntlm3-1.0.1-py2.7.egg\ntlm3\des_dat
a.py", line 25, in <module>
U32(0x00820200), U32(0x00020000), U32(0x80800000), U32(0x80820200),
File "C:\python27\lib\site-packages\python_ntlm3-1.0.1-py2.7.egg\ntlm3\U32.py"
, line 32, in __init__
value = six.byte2int(value)
File "C:\python27\lib\site-packages\six-1.8.0-py2.7.egg\six.py", line 605, in
byte2int
return ord(bs[0])
TypeError: 'long' object is not subscriptable
Sorry about that! Package maintainer here.
It looks like it was a problem with Windows. I just released v1.0.2 which fixes this and added Appveyor support to catch these problems in future.
Edit: On a Windows PC you probably hit the error with pip HttpNtlmAuth to fix it you will need to pip requests_ntlm to get v1.0.2.
Not an answer, however:
I've opened a GitHub issue for this bug: https://github.com/trustrachel/python-ntlm3/issues/6 .
Currently the workaround is to use requests-ntlm version 0.0.3.
I also struggled with this problem when I am on
Python 3.7.0
requests-ntlm==1.1.0
Finally SOLVED with different version
Python 3.7.0
requests-ntlm==0.1.0
I had the same issue while connecting to SharePoint using SSO(Single Sign-On)
The following statement solved my problem:
pip install requests_ntlm

Old error message keep popping up on IDLE

For some reason, anytime I try to import a python library, a particular old error message keeps popping up.
However, everything works fine when working with shell.
I know this is not a real programming question, but I'm stuck and would appreciate any help.
Any ideas on how to fix this?
Error message
>>> import nltk
Traceback (most recent call last):
File "<pyshell#3>", line 1, in <module>
import nltk
File "C:\Python27\lib\site-packages\nltk\__init__.py", line 91, in <module>
from internals import config_java
File "C:\Python27\lib\site-packages\nltk\internals.py", line 22, in <module>
except ImportError: from xml.etree import ElementTree
ImportError: No module named etree
Does "C:\Python27\lib\xml\etree\ElementTree.py" exist in your computer?
Since IDLE and shell behaves differently, you may try the two lines in IDLE and Shell:
import sys
sys.path
Then check the difference of env path

Categories

Resources