Cannot import Exscript into Python - python

I'm using windows 10, and I have a script to SSH to the device and do some configurations:
from Exscript import Account
from Exscript.protocols import SSH2
account = Account("user","password")
conn = SSH2()
conn.connect('192.168.200.2')
conn.login(account)
But I get the following error:
Traceback (most recent call last):
File "c:\Users\hp\Desktop\password-finder.py", line 2, in <module>
from Exscript.protocols import SSH2
File "c:\Users\hp\AppData\Local\Programs\Python\Python310\lib\site-packages\Exscript\__init__.py", line 34, in <module>
from .queue import Queue
File "c:\Users\hp\AppData\Local\Programs\Python\Python310\lib\site-packages\Exscript\queue.py", line 40, in <module>
from .util.decorator import get_label
File "c:\Users\hp\AppData\Local\Programs\Python\Python310\lib\site-packages\Exscript\util\decorator.py", line 28, in <module>
from ..protocols.exception import LoginFailure
File "c:\Users\hp\AppData\Local\Programs\Python\Python310\lib\site-packages\Exscript\protocols\__init__.py", line 26, in <module>
from ..util.url import Url
File "c:\Users\hp\AppData\Local\Programs\Python\Python310\lib\site-packages\Exscript\util\url.py", line 36, in <module>
from .collections import OrderedDefaultDict
File "c:\Users\hp\AppData\Local\Programs\Python\Python310\lib\site-packages\Exscript\util\collections.py", line 9, in <module>
from collections import OrderedDict, Callable, defaultdict
ImportError: cannot import name 'Callable' from 'collections' (c:\Users\hp\AppData\Local\Programs\Python\Python310\lib\collections\__init__.py)
Update:
Not a perfect solution but works for me:
remove Callable keyword in line 9 of file Exscript\util\collections.py:
from collections import OrderedDict, Callable, defaultdict
to:
from collections import OrderedDict, defaultdict

(I have to make an answer to comment sorry)
do you have collections installed in python? just to check open cmd and type:
pip install collections
if it says: Requirement already satisfied then i will dig deeper and see what I can find
edit: I'm having the same issue, ill try debugging

Related

s3fs/botocore import error: InvalidIMDSEndpointError

I was trying to run some python code in docker and export a .csv file to S3, but got the same error as in aiobotocore - ImportError: cannot import name 'InvalidIMDSEndpointError' (asking here because I don't have enough reputation to comment under that thread..)
File "/opt/conda/lib/python3.7/site-packages/s3fs/__init__.py", line 1, in <module>
from .core import S3FileSystem, S3File
File "/opt/conda/lib/python3.7/site-packages/s3fs/core.py", line 14, in <module>
import aiobotocore
File "/opt/conda/lib/python3.7/site-packages/aiobotocore/__init__.py", line 1, in <module>
from .session import get_session, AioSession
File "/opt/conda/lib/python3.7/site-packages/aiobotocore/session.py", line 6, in <module>
from .client import AioClientCreator, AioBaseClient
File "/opt/conda/lib/python3.7/site-packages/aiobotocore/client.py", line 12, in <module>
from .utils import AioS3RegionRedirector
File "/opt/conda/lib/python3.7/site-packages/aiobotocore/utils.py", line 10, in <module>
from botocore.exceptions import (
ImportError: cannot import name 'InvalidIMDSEndpointError' from 'botocore.exceptions' (/opt/conda/lib/python3.7/site-packages/botocore/exceptions.py)
I tried to use the versions of libraries as in the comment:
botocore==1.19.52
s3fs==0.5.1
boto3==1.16.52
aiobotocore==1.2.0
However, these don't solve the problem and I still get the same error.
Could anyone here give me some hints how to solve this?
Thanks!
Ok, I can answer my own question :)
Just install s3fs, and it will take care of version dependencies of other libraries..

Whenever I run my discord bot using discord.py I'm getting an AttributeError 'logging' has no attribute 'getlogger'

All my code is on github except for the token.py file for obvious reasons.
bot.py file
I have had similar issues in the past and have resolved them by reconstructing some code so I apologize in advance if this is another one of those issues where I missed a capital or something but I have tried all the obvious syntax issues and none of them seemed to work. Atom also didn't show any errors.
Here is the whole error message:
Traceback (most recent call last):
File "C:\Users\james\Documents\botpy\bot.py", line 5, in <module>
import discord
File "C:\Users\james\AppData\Local\Programs\Python\Python38-32\lib\site-packages\discord\__init__.py", line 21, in <module>
import logging
File "C:\Users\james\AppData\Local\Programs\Python\Python38-32\lib\logging\__init__.py", line 26, in <module>
import sys, os, time, io, re, traceback, warnings, weakref, collections.abc
File "C:\Users\james\AppData\Local\Programs\Python\Python38-32\lib\traceback.py", line 5, in <module>
import linecache
File "C:\Users\james\AppData\Local\Programs\Python\Python38-32\lib\linecache.py", line 11, in <module>
import tokenize
File "C:\Users\james\AppData\Local\Programs\Python\Python38-32\lib\tokenize.py", line 34, in <module>
from token import *
File "C:\Users\james\Documents\botpy\token.py", line 2, in <module>
from discord.ext import commands
File "C:\Users\james\AppData\Local\Programs\Python\Python38-32\lib\site-packages\discord\ext\commands\__init__.py", line 13, in <module>
from .bot import Bot, AutoShardedBot, when_mentioned, when_mentioned_or
File "C:\Users\james\AppData\Local\Programs\Python\Python38-32\lib\site-packages\discord\ext\commands\bot.py", line 27, in <module>
import asyncio
File "C:\Users\james\AppData\Local\Programs\Python\Python38-32\lib\asyncio\__init__.py", line 8, in <module>
from .base_events import *
File "C:\Users\james\AppData\Local\Programs\Python\Python38-32\lib\asyncio\base_events.py", line 18, in <module>
import concurrent.futures
File "C:\Users\james\AppData\Local\Programs\Python\Python38-32\lib\concurrent\futures\__init__.py", line 8, in <module>
from concurrent.futures._base import (FIRST_COMPLETED,
File "C:\Users\james\AppData\Local\Programs\Python\Python38-32\lib\concurrent\futures\_base.py", line 42, in <module>
LOGGER = logging.getLogger("concurrent.futures")
AttributeError: partially initialized module 'logging' has no attribute 'getLogger' (most likely due to a circular import)
Try to rename your file into main.py
I had a similar error just because the filename.

when I run this code it shows error

filename='metamorphosis_clean.txt'
file=open(filename,'rt')
text=file.read()
file.close()
from nltk import sent_tokenize
sentences=sent_tokenize(text)
print(sentences[0])
Error:
Traceback (most recent call last):
File "split_into_sentenes.py", line 1, in <module>
import nltk
File "/usr/local/lib/python2.7/dist-packages/nltk/__init__.py", line 114, in <module>
from nltk.collocations import *
File "/usr/local/lib/python2.7/dist-packages/nltk/collocations.py", line 37, in <module>
from nltk.probability import FreqDist
File "/usr/local/lib/python2.7/dist-packages/nltk/probability.py", line 47, in <module>
from collections import defaultdict, Counter
File "/usr/local/lib/python2.7/dist-packages/nltk/collections.py", line 13, in <module>
import pydoc
File "/usr/lib/python2.7/pydoc.py", line 56, in <module>
import sys, imp, os, re, types, inspect, __builtin__, pkgutil, warnings
File "/usr/lib/python2.7/inspect.py", line 39, in <module>
import tokenize
File "/usr/lib/python2.7/tokenize.py", line 39, in <module>
COMMENT = N_TOKENS
NameError: name 'N_TOKENS' is not defined
In all likelihood you have a file named token.py in the current directory, i.e. the directory from which you are running your split_into_sentenes.py script.
If present locally, token.py will be imported before the one in the standard library, and this would result in the error that you see.
Check whether it exists and if necessary rename it to something that doesn't clash with the standard library.

Having an import error with discord.py

I'm trying to build a discord bot, and I have this error that I can't seem to figure out that explicitly happens when I try to import discord.py
The error message is:
Traceback (most recent call last):
File "C:/Users/Pastry/PycharmProjects/PastryBot/sample.py", line 1, in <module>
import discord
File "C:\Python35\lib\site-packages\discord\__init__.py", line 20, in <module>
from .client import Client, AppInfo, ChannelPermissions
File "C:\Python35\lib\site-packages\discord\client.py", line 28, in <module>
from .user import User
File "C:\Python35\lib\site-packages\discord\user.py", line 27, in <module>
from .utils import snowflake_time
File "C:\Python35\lib\site-packages\discord\utils.py", line 31, in <module>
import asyncio
File "C:\Python35\lib\asyncio\__init__.py", line 21, in <module>
from .base_events import *
File "C:\Python35\lib\asyncio\base_events.py", line 18, in <module>
import concurrent.futures
File "C:\Python35\lib\concurrent\futures\__init__.py", line 17, in <module>
from concurrent.futures.process import ProcessPoolExecutor
File "C:\Python35\lib\concurrent\futures\process.py", line 55, in <module>
from multiprocessing.connection import wait
File "C:\Python35\lib\multiprocessing\connection.py", line 18, in <module>
import tempfile
File "C:\Python35\lib\tempfile.py", line 45, in <module>
from random import Random as _Random
ImportError: cannot import name 'Random'
I tried using the sample code from the quickstart bot guide on their documentation page as well, and ran into the same error. I thought it was a problem with my version of discord.py so I tried to update it, and then re-ran the program but I'm still getting this error. Could anyone help enlighten me?
Did you download the discord.py library? that could be the the problem. What about the asyncio library? Those two are most likely.

Mac system generate error message when I call python script on terminal

My code is simply the follow and work few days ago:
import pandas as pd
df = pd.read_csv('WORLDBANK-ZAF_MYS_PROP_4044_SEC_MF.csv')
print(df.head())
But now whenever I try to run it by calling python my_io.py on my Mac terminal it generates the following messages:
Bases-MacBook-Pro:data_analysis me$ python my_io.py
Traceback (most recent call last):
File "my_io.py", line 1, in
import pandas as pd
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pandas/init.py", line 13, in
import(dependency)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/numpy/init.py", line 142, in
from . import add_newdocs
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/numpy/add_newdocs.py", line 13, in
from numpy.lib import add_newdoc
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/numpy/lib/init.py", line 8, in
from .type_check import *
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/numpy/lib/type_check.py", line 11, in
import numpy.core.numeric as _nx
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/numpy/core/init.py", line 72, in
from numpy.testing.nosetester import _numpy_tester
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/numpy/testing/init.py", line 12, in
from . import decorators as dec
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/numpy/testing/decorators.py", line 20, in
from .utils import SkipTest, assert_warns
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/numpy/testing/utils.py", line 15, in
from tempfile import mkdtemp, mkstemp
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/tempfile.py", line 32, in
import io as _io
File "/Users/gongzhuli/Desktop/data_analysis/io.py", line 3, in
AttributeError: 'module' object has no attribute 'read_csv'
Can someone please help me, I have no idea what is going on here..
Your file is called io.py, which is a library module to handle file-like buffers among other things.
pandas imports tempfile which needs it:
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/tempfile.py", line 32, in <module>
import io as _io
and your filename gets in the way of the import chain and prevents import from going through.
Just rename your file with something more specific (like my_io.py for instance?)

Categories

Resources