Issue with google library in python - 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

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.

ImportError: cannot import name 'winrandom'

I know that this question has already a ton of answers but unfortunately this hasn't fixed the issue for me. I want to run some code using PyCrytpo but winrandom doesn't want to get import.
All the other posts are for earlier releases of python. I am using Python 3.6.5 and renaming code within nt.py file to "from . import winrandom" doesn't do the trick for me.
Do you have any suggestions or is a rollback the only opportunity?
Windows 10
Python 3.6.5
Anaconda
from Crypto.PublicKey import RSA
Traceback (most recent call last):
File "<ipython-input-39-b6fe4d249eef>", line 1, in <module>
from Crypto.PublicKey import RSA
File "C:\Users\Markus\Anaconda3\lib\site-packages\Crypto\PublicKey\RSA.py", line 78, in <module>
from Crypto import Random
File "C:\Users\Markus\Anaconda3\lib\site-packages\Crypto\Random\__init__.py", line 28, in <module>
from Crypto.Random import OSRNG
File "C:\Users\Markus\Anaconda3\lib\site-packages\Crypto\Random\OSRNG\__init__.py", line 34, in <module>
from Crypto.Random.OSRNG.nt import new
File "C:\Users\Markus\Anaconda3\lib\site-packages\Crypto\Random\OSRNG\nt.py", line 28, in <module>
from . import winrandom
ImportError: cannot import name 'winrandom'

Can only run my copy_files.py from one directory

I can run my copy_files.py script from only one directory.
When I run it from other directories, I get the following errors:
Traceback (most recent call last):
File "./copy_py", line 36, in <module>
import paramiko
File "/usr/local/lib/python3.6/site-packages/paramiko/__init__.py", line 22, in <module>
from paramiko.transport import SecurityOptions, Transport
File "/usr/local/lib/python3.6/site-packages/paramiko/transport.py", line 56, in <module>
from paramiko.dsskey import DSSKey
File "/usr/local/lib/python3.6/site-packages/paramiko/dsskey.py", line 27, in <module>
from cryptography.hazmat.primitives.asymmetric.utils import (
File "/usr/local/lib/python3.6/site-packages/cryptography/hazmat/primitives/asymmetric/utils.py", line 9, in <module>
from asn1crypto.algos import DSASignature
File "/usr/local/lib/python3.6/site-packages/asn1crypto/algos.py", line 26, in <module>
from .core import (
File "/usr/local/lib/python3.6/site-packages/asn1crypto/core.py", line 53, in <module>
import copy
File "/home/xjacrawf/work/pyth/copy.py", line 106, in <module>
cli = paramiko.client.SSHClient()
AttributeError: module 'paramiko' has no attribute 'client'
I have tried to remove all of the script's body, even renamed the script.
#!/usr/local/bin/python3.6
import sys
sys.path.insert(0, "/usr/local/lib/python3.6/site-packages")
import cx_Oracle
import glob
import os
import time
import paramiko
from scp import SCPClient
cli = paramiko.client.SSHClient()
cli.set_missing_host_key_policy(paramiko.client.AutoAddPolicy())
I expect the script to establish a connection, and it just errors.
I run the script from the first directory it ran from $MDS_SRC/ and it runs fine.
I can copy the entire script to my local directory , and it errors out.

Newspaper module import problems on Beanstalk

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!

Run Python program as administrator from command line

I'm trying to run my program as an administrator from the command line. Seems quite easy but I'm struggling.
I started with this, which works fine launched from the Python IDLE:
import dropbox, pymysql, shlex, shutil, subprocess
import logging
import sshtunnel
from sshtunnel import SSHTunnelForwarder
# Main program starts here
print("Hello World!")
but that gave an error as follows:
pi#jsmd:~ $ sudo python /home/pi/Documents/iot_pm2/iot.py
Traceback (most recent call last):
File "/home/pi/Documents/iot_pm2/iot.py", line 3, in <module>
import dropbox, pymysql, shlex, shutil, subprocess
ImportError: No module named pymysql
After some Googling I added two lines at the start:
import sys
sys.path.append("/usr/local/lib/python3.4/dist-packages/")
This also works fine from the Python IDLE but gives a long error trace when run from the command line... and I'm not good enough at understanding how to read the trace and hence what I can do to fix it. (Plus I don't understand why it works from the IDLE as a non-admin but not from the command line as an admin.) Can anyone help?
pi#jsmd:~ $ sudo python /home/pi/Documents/iot_pm2/iot.py
Traceback (most recent call last):
File "/home/pi/Documents/iot_pm2/iot.py", line 5, in <module>
import sshtunnel
File "/usr/local/lib/python3.4/dist-packages/sshtunnel.py", line 25, in <module>
import paramiko
File "/usr/local/lib/python3.4/dist-packages/paramiko/__init__.py", line 30, in <module>
from paramiko.transport import SecurityOptions, Transport
File "/usr/local/lib/python3.4/dist-packages/paramiko/transport.py", line 50, in <module>
from paramiko.dsskey import DSSKey
File "/usr/local/lib/python3.4/dist-packages/paramiko/dsskey.py", line 26, in <module>
from Crypto.PublicKey import DSA
File "/usr/local/lib/python3.4/dist-packages/Crypto/PublicKey/DSA.py", line 89, in <module>
from Crypto import Random
File "/usr/local/lib/python3.4/dist-packages/Crypto/Random/__init__.py", line 29, in <module>
from Crypto.Random import _UserFriendlyRNG
File "/usr/local/lib/python3.4/dist-packages/Crypto/Random/_UserFriendlyRNG.py", line 38, in <module>
from Crypto.Random.Fortuna import FortunaAccumulator
File "/usr/local/lib/python3.4/dist-packages/Crypto/Random/Fortuna/FortunaAccumulator.py", line 39, in <module>
from . import FortunaGenerator
File "/usr/local/lib/python3.4/dist-packages/Crypto/Random/Fortuna/FortunaGenerator.py", line 35, in <module>
from Crypto.Util import Counter
File "/usr/local/lib/python3.4/dist-packages/Crypto/Util/Counter.py", line 59, in <module>
from Crypto.Util import _counter
ImportError: cannot import name _counter
Thanks.
is the default of python is 3 ? If not try to execute like this: sudo
python3 ... – #Koffee
Thanks to #Koffee we have an answer and this thread can be marked as solved and closed.

Categories