# To set parameters to pip config
pip config set global.trusted-host "pypi.python.org pypi.org files.pythonhosted.org" --trusted-host=pypi.python.org --trusted-host=pypi.org --trusted-host=files.pythonhosted.org
# saves to: C:\Users\a126291\AppData\Roaming\pip\pip.ini
Request verify=False monkey patch
# we should always use verify=cafile (or verify=False) instead of using this monkey patchimportrequests.apiimportwarningsdefrequestspatch(method, url, **kwargs):
kwargs['verify'] =Falsereturn_origcall(method, url, **kwargs)
_origcall=requests.api.requestrequests.api.request=requestspatchwarnings.warn('Patched requests: SSL verification disabled!')
SSL Certification Error
importosimportrequestsimportpandasaspdimportio# add the certificatecertificate_path="certificates/caadmin.netskope.com"os.environ["REQUESTS_CA_BUNDLE"] =certificate_path# get the dataurl="https://raw.githubusercontent.com/unit8co/darts/master/datasets/AirPassengers.csv"response=requests.get(url)
ifresponse.status_code==200:
data=response.contentdf=pd.read_csv(io.StringIO(data.decode('utf-8')))
print(df.head())
else:
print("Failed to download the data. Status code:", response.status_code)
Encoding error
Error:
UnicodeDecodeError: 'utf-8'codeccan'tdecodebyte0xffinposition0: invalidstartbyteTroubleshoot:
df=pd.read_csv('market_share.txt',sep=r'\s+',encoding='utf-16')
# errors = ignore will remove some unparsed character that we dont care.withopen(infile, encoding='utf-16',errors='ignore') asfi:
text=fi.readlines()
About
Various troubleshoots of errors and warnings encountered
Apache License 2.0
Languages
Language:Jupyter Notebook 94.2%Language:DIGITAL Command Language 5.8%