Cannot import name 'Instalysis' from 'instagramy' - python-3.x

I cannot figure out what this error requires... any ideas for a Python newbie? All pre requisites are installed... this is version 3.9 64-bit.
Details: "ADO.NET: Python script error.
ImportError: cannot import name 'Instalysis' from 'instagramy' (C:\Python\Python39\lib\site-packages\instagramy_init_.py)
"
Here's the test script I'm running:
from instagramy import Instalysis
# Instagram user_id of ipl teams
teams = ["chennaiipl", "mumbaiindians",
"royalchallengersbangalore", "kkriders",
"delhicapitals", "sunrisershyd",
"kxipofficial"]
data = Instalysis(teams)
# return the dataframe
data_frame = data.analyis()
data_frame

The instagramy package doesn't have the 'Instalysis' section to it. But it does have these:
from instagramy import InstagramUser
This will give uyou all of the info also I saw that you had parentheses at data_frame = data.analyis()
You will recieve an error if you have them as it isn't an executable function.
Go have a look at the pypi page here: Pypi- Instagramy
Hope this could help!

Related

decodestrings is not an attribute of base64 error in python 3.9.1

After upgrading from python 3.8.0 to python 3.9.1, the tremc front-end of transmission bitTorrent client is throwing decodestrings is not an attribute of base64 error whenever i click on a torrent entry to check the details.
My system specs:
OS: Arch linux
kernel: 5.6.11-clear-linux
base64.encodestring() and base64.decodestring(), aliases deprecated since Python 3.1, have been removed.
use base64.encodebytes() and base64.decodebytes()
So i went to the site-packages directory and with ripgrep tried searching for the decodestring string.
rg decodestring
paramiko/py3compat.py
39: decodebytes = base64.decodestring
Upon examining the py3compat.py file,i found this block:
PY2 = sys.version_info[0] < 3
if PY2:
string_types = basestring # NOQA
text_type = unicode # NOQA
bytes_types = str
bytes = str
integer_types = (int, long) # NOQA
long = long # NOQA
input = raw_input # NOQA
decodebytes = base64.decodestring
encodebytes = base64.encodestring
So decodebytes have replaced(aliased) decodestring attribute of base64 for python version >= 3
This must be a new addendum because tremc was working fine in uptil version 3.8.*.
Opened tremc script, found the erring line (line 441), just replaced the attribute decodestring with decodebytes.A quick fix till the next update.
PS: Checked the github repository, and there's a pull request for it in waiting.
If you don't want to wait for the next release and also don't want to hack the way i did, you can get it freshly build from the repository, though that would be not much of a difference than my method

is there a way to convert a python script into one class or a package?

I am migrating data from IBM to Snowflake in
3 stages- extract, transform and load.
Below is the python code that connects source IBM and destination Snowflake which does the ETL.
is there any way I can create a class/ package out of the entire below code?
import snowflake.connector
tableName='F58001'
ctx = snowflake.connector.connect(
user='*',
password='*',
account='*.azure'
)
cs = ctx.cursor()
ctx.cursor().execute("USE DATABASE STORE_PROFILE")
ctx.cursor().execute("USE SCHEMA LANDING")
try:
ctx.cursor().execute("PUT file:///temp/data/{tableName}/* #%{tableName}".format(tableName=tableName))
except Exception:
pass
ctx.cursor().execute("truncate table {tableName}".format(tableName=tableName))
ctx.cursor().execute("COPY INTO {tableName} ON_ERROR = 'CONTINUE' ".format(tableName=tableName,
FIELD_OPTIONALLY_ENCLOSED_BY = '""', sometimes=',', ERROR_ON_COLUMN_COUNT_MISMATCH = 'TRUE'))
last_query_id= ctx.cursor().execute("select last_query_id()")
for res in last_query_id:
query_id = res[0]
ctx.cursor().execute(f"create or replace table save_copy_errors as select * from
table(validate("+tableName+", job_id=> "+"'"+query_id+"'"+"))")
ax = ctx.cursor().execute("select * from save_copy_errors")
for errors in ax:
error = errors
print(error)
ctx.close()
Please look at the below repository. It probably has answer to your question. I am currently working on moving it to PYPI so that it can be installed with PIP
https://github.com/Infosys/Snowflake-Python-Development-Framework

No module named 'chaterbot'

I was trying to do a tutorial on youtube, when i ran the code visual studio selects line 3 and I can read: Exception has occurred: ModuleNotFoundError
No module named 'chaterbot'
I have chatterbot 1.0.4 installed, i'll leave the code below for anyone who could help me, thank you for your help.
Code:
from chatterbot import ChatBot
bot = ChatBot(
'Eustaquio',
storage_adapter="chaterbot.storage.SQLStorageAdapter",
logic_adapter=[
'chatterbot.logic.BestMatch',
'chatterbot.logic.TimeLogicAdapter',
'chatterbot.logic.MathematicalEvaluation'
],
input_adapters="chatterbot.input.TerminalAdapter",
output_adapter="chatterbot.output.TerminalAdapter",
database = './tutorial'
)
while True:
boti = bot.get_response(None)
from chatterbot import ChatBot
bot = ChatBot(
'Eustaquio',
storage_adapter="chaterbot.storage.SQLStorageAdapter",
logic_adapter=[
'chatterbot.logic.BestMatch',
'chatterbot.logic.TimeLogicAdapter',
'chatterbot.logic.MathematicalEvaluation'
],
input_adapters="chatterbot.input.TerminalAdapter",
output_adapter="chatterbot.output.TerminalAdapter",
database = './tutorial'
)
while True:
boti = bot.get_response(None)
Thats not "chaterbot". It's "chatterbot" (line 4)

I am using JIRA Python API to create Issue

I am using following code to create an issue :
from jira import JIRA
import pandas as pd
user = 'XXXXXXXXXXXXXXX#gmail.com'
apikey = 'XXXXXXXXXXXXXXXXXXXXXXX'
server = 'https://XXXXXXX.atlassian.net'
options = {'server': server}
jira = JIRA(options, basic_auth=(user,apikey) )
# summary = issue.fields.summary
issue_List=[]
readexcel=pd.read_excel(r'test1.xlsx')
for item in readexcel.index:
isssue_dict=dict()
isssue_dict['project']=dict({'key':'MYB'})
isssue_dict['summary']=readexcel['Summary'][item]
isssue_dict['description']=readexcel['Description'][item]
isssue_dict['issuetype']=dict({'name':'Bug'})
# isssue_dict['customfield_10014']=readexcel['Epic Link'][item]
isssue_dict['priority']={'name':readexcel['Priority'][item]}
isssue_dict['labels']=[readexcel['Labels'][item]]
isssue_dict['reporter'] :dict({'name':readexcel['Reporter'][item]})
isssue_dict['assignee']=[readexcel['Assignee'][item]]
new_issue = jira.create_issue(fields=isssue_dict)
print(new_issue._str_())
I am not able to put {versions:[{`Affects Version\s':Affects version}]} and Epic Link on Jira issue
In order to set the Epic information, please use add_issues_to_epic(epic_id, issue_keys, ignore_epics=True).
If the version already exists, use the keys versions and fixVersions to set the Affected Version and Fix Version.
See https://jira.readthedocs.io/en/master/api.html for a full documentation of these methods.

File Partially Download with urllib.request.urlretrieve

I have this code Which is trying to retrieve file from Git Hub Repositories.
import os
import tarfile
from six.moves import urllib
import urllib.request
DOWNLOAD_ROOT = "https://github.com/ageron/handson-ml/tree/master/"
HOUSING_PATH = os.path.join("datasets", "housing").replace("\\","/")
print(HOUSING_PATH)
HOUSING_URL = DOWNLOAD_ROOT + HOUSING_PATH
print(HOUSING_URL)
print(os.getcwd())
def fetch_housing_data(housing_url=HOUSING_URL, housing_path=HOUSING_PATH):
if not os.path.isdir(housing_path):
os.makedirs(housing_path)
tgz_path = os.path.join(housing_path, "housing.tgz").replace("\\","/")
print(tgz_path)
urllib.request.urlretrieve(housing_url, tgz_path)
housing_tgz = tarfile.open(tgz_path)
housing_tgz.extractall(path=housing_path)
housing_tgz.close()
fetch_housing_data()
After Executing the code I got this Error ReadError: file could not be opened successfully. I did checked the actual file size and the file which is download after executing this code and I came to know that file is downloaded partially.
So is their any way to download the whole file ? Thanks in Advance
Finally I got the problem. It was with the link that I was using to retrieve the file. I didn't knew that RAW link should be used along with the file name (Not using file name will give you 404 Error) in Git Hub Repositories.
So I little bit of modification is needs to be done in actual code posted in my question.
That is :
Change the link from
DOWNLOAD_ROOT = "https://github.com/ageron/handson-ml/tree/master/"
To this :
DOWNLOAD_ROOT = "https://raw.githubusercontent.com/ageron/handson-ml/master/"
And this
HOUSING_URL = DOWNLOAD_ROOT + HOUSING_PATH
to
HOUSING_URL = DOWNLOAD_ROOT + "datasets/housing/housing.tgz" \\**( Actual File name is needed)**
Thank you !

Resources