Newspaper module import problems on Beanstalk - python

Has anyone tried using newspaper3k python library on AWS Elastic Beanstalk Python 3.4?
I'm getting a strange error, despite images.py existing in the newspaper directory.
Traceback (most recent call last):
File "/opt/python/current/app/application.py", line 12, in <module>
from server.helper import get_connection, requires_auth, validate_schema, error_handler
File "/opt/python/current/app/server/helper.py", line 13, in <module>
from database.user import User
File "/opt/python/current/app/database/user.py", line 11, in <module>
from .post import Post
File "/opt/python/current/app/database/post.py", line 9, in <module>
from newspaper import Article
File "/opt/python/run/venv/lib/python3.4/site-packages/newspaper/__init__.py", line 10,in <module>
from .api import (build, build_article, fulltext, hot, languages,
File "/opt/python/run/venv/lib/python3.4/site-packages/newspaper/api.py", line 14, in <module>
from .article import Article
File "/opt/python/run/venv/lib/python3.4/site-packages/newspaper/article.py", line 14, in <module>
from . import images
ImportError: cannot import name 'images'
I have installed all dependencies (Pillow, lxml, libjpeg etc.) correctly and surprisingly when I ssh to instance it works properly.
Any help would be appreciated, thanks!

Related

i've been making a discord bot on replit. it's been working perfectly then today it broke

my bot has been running perfectly on replit for 2 days now. I used replit servers and uptimerobot to keep it up and running and it worked flawlessly until suddenly the bot goes offline.
I check the code and it has stopped working all it gives me is this error code:
Traceback (most recent call last):
File "main.py", line 1, in <module>
import discord
File "/home/runner/discord-bot/venv/lib/python3.8/site-packages/discord/__init__.py", line 25, in <module>
from .client import Client
File "/home/runner/discord-bot/venv/lib/python3.8/site-packages/discord/client.py", line 33, in <module>
import aiohttp
File "/home/runner/discord-bot/venv/lib/python3.8/site-packages/aiohttp/__init__.py", line 6, in <module>
from .client import (
File "/home/runner/discord-bot/venv/lib/python3.8/site-packages/aiohttp/client.py", line 35, in <module>
from . import hdrs, http, payload
File "/home/runner/discord-bot/venv/lib/python3.8/site-packages/aiohttp/http.py", line 7, in <module>
from .http_parser import (
File "/home/runner/discord-bot/venv/lib/python3.8/site-packages/aiohttp/http_parser.py", line 15, in <module>
from .helpers import NO_EXTENSIONS, BaseTimerContext
File "/home/runner/discord-bot/venv/lib/python3.8/site-packages/aiohttp/helpers.py", line 48, in <module>
from typing_extensions import Protocol
ModuleNotFoundError: No module named 'typing_extensions'
Personally I use replit as well this seems like a package error, try deleting the package configuration files found on your repl and try re running the program so it'll re install your packages. If this doesn't work try running pip install typing_extensions in the shell.

Import error: No module named 'secrets' - python manage.py not working after pull to Digital Ocean

I'm following along a course - Django development to deployment.
After pulling it to Digital Ocean everything else ran smoothly. Until
I tried running python manage.py help
(env) djangoadmin#ubuntu-1:~/pyapps/btre_project_4$ python manage.py help
and I get this error.
Traceback (most recent call last):
File "manage.py", line 21, in <module>
main()
File "manage.py", line 17, in main
execute_from_command_line(sys.argv)
File "/home/djangoadmin/pyapps/env/lib/python3.5/site-packages/django/core/management/__init__.py", line 401, in execute_from_command_line
utility.execute()
File "/home/djangoadmin/pyapps/env/lib/python3.5/site-packages/django/core/management/__init__.py", line 377, in execute
django.setup()
File "/home/djangoadmin/pyapps/env/lib/python3.5/site-packages/django/__init__.py", line 16, in setup
from django.urls import set_script_prefix
File "/home/djangoadmin/pyapps/env/lib/python3.5/site-packages/django/urls/__init__.py", line 1, in <module>
from .base import (
File "/home/djangoadmin/pyapps/env/lib/python3.5/site-packages/django/urls/base.py", line 9, in <module>
from .exceptions import NoReverseMatch, Resolver404
File "/home/djangoadmin/pyapps/env/lib/python3.5/site-packages/django/urls/exceptions.py", line 1, in <module>
from django.http import Http404
File "/home/djangoadmin/pyapps/env/lib/python3.5/site-packages/django/http/__init__.py", line 2, in <module>
from django.http.request import (
File "/home/djangoadmin/pyapps/env/lib/python3.5/site-packages/django/http/request.py", line 10, in <module>
from django.core import signing
File "/home/djangoadmin/pyapps/env/lib/python3.5/site-packages/django/core/signing.py", line 45, in <module>
from django.utils.crypto import constant_time_compare, salted_hmac
File "/home/djangoadmin/pyapps/env/lib/python3.5/site-packages/django/utils/crypto.py", line 6, in <module>
import secrets
ImportError: No module named 'secrets'
I'm a newbie and have been stuck on this for a while. I just want to know what could possibly cause this.
The secrets module was added to Python in version 3.6. Your host is using Python 3.5, hence the secrets module is unavailable. You need a host with Python 3.6+, or a version of Django that doesn't depend on the secrets module
Had the same issue, solved it by specifying the python version I have installed. i.e
$ python3
>>> import secrets
>>> secrets.token_hex(16)

Issue with google library in python

I am running into an error when importing the below library
from google.cloud import vision
The error message I receive is :
Traceback (most recent call last):
File "d:/UnmatchedOTMProcess/ImageDetection_test.py", line 2, in <module>
from google.cloud import vision
File "C:\Users\mhancock\AppData\Roaming\Python\Python38\site-packages\google\cloud\vision.py", line
17, in <module>
from google.cloud.vision_v1 import ImageAnnotatorClient
File "C:\Users\mhancock\AppData\Roaming\Python\Python38\site-
packages\google\cloud\vision_v1\__init__.py", line 27, in <module>
from google.cloud.vision_v1.gapic import image_annotator_client as iac
File "C:\Users\mhancock\AppData\Roaming\Python\Python38\site-
packages\google\cloud\vision_v1\gapic\image_annotator_client.py", line 24, in <module>
import google.api_core.gapic_v1.client_info
File "C:\Users\mhancock\AppData\Roaming\Python\Python38\site-
packages\google\api_core\gapic_v1\__init__.py", line 16, in <module>
from google.api_core.gapic_v1 import config
File "C:\Users\mhancock\AppData\Roaming\Python\Python38\site-
packages\google\api_core\gapic_v1\config.py", line 23, in <module>
import grpc
File "C:\Users\mhancock\AppData\Roaming\Python\Python38\site-packages\grpc\__init__.py", line 23, in
<module>
from grpc._cython import cygrpc as _cygrpc
ImportError: cannot import name 'cygrpc' from 'grpc._cython'
(C:\Users\mhancock\AppData\Roaming\Python\Python38\site-packages\grpc\_cython\__init__.py)
The code works perfectly on my local machine, however trying to run this on a gcp virtual machine and the environment must be slightly different somehow.
Appreciate any assistance!
Thanks in advance,
Matt

Python import error on one machine, but not on the other

I'm using a library called newspaper and deploying my app to elastic beanstalk. It runs fine locally, but on the server it doesn't work and throws this error:
File "/opt/python/current/app/application.py", line 7, in <module>
from api.v01.api import apiv01
File "/opt/python/current/app/api/v01/api.py", line 19, in <module>
from newspaper import Article
File "/opt/python/run/venv/lib/python2.7/site-packages/newspaper/__init__.py", line 10, in <module>
from .article import Article, ArticleException
File "/opt/python/run/venv/lib/python2.7/site-packages/newspaper/article.py", line 12, in <module>
from . import images
ImportError: cannot import name images
Both machines are running python 2.7.9.
What could the problem be?
Just to confirm, I'm using requirements.txt to load the dependencies, and they are loaded fine on both machines.

Error with newrelic and zope

I'm trying to configure newrelic with zope but it is returning the error:
# bin/newrelic-admin run-python bin/zeoserver fg
Traceback (most recent call last):
File "bin/zeoserver", line 22, in <module>
import plone.recipe.zeoserver.ctl
File "/opt/bitnami/apps/plone/buildout-cache/eggs/plone.recipe.zeoserver-1.2.6-py2.7.egg/plone/recipe/zeoserver/__init__.py", line 9, in <module>
import zc.recipe.egg
File "/opt/bitnami/apps/plone/buildout-cache/eggs/zc.recipe.egg-1.3.2-py2.7.egg/zc/recipe/egg/__init__.py", line 1, in <module>
from zc.recipe.egg.egg import Egg, Scripts, Eggs
File "/opt/bitnami/apps/plone/buildout-cache/eggs/zc.recipe.egg-1.3.2-py2.7.egg/zc/recipe/egg/egg.py", line 21, in <module>
import zc.buildout.easy_install
File "/opt/bitnami/apps/plone/buildout-cache/eggs/zc.buildout-2.2.5-py2.7.egg/zc/buildout/easy_install.py", line 81, in <module>
pkg_resources.Requirement.parse('zc.buildout')).location,
AttributeError: 'NoneType' object has no attribute 'location'
Does anyone know what can it be pls?
I solved adding the below code in a __init__.py from application:
import newrelic.agent
newrelic.agent.initialize('path/of/newrelic.ini')
And execute the application without the command "newrelic-admin run-python".
Newrelic worked but with limitations because don't have official support yet.

Categories