This simple code works in Microsoft Edge but not in Chrome (both using Jupyter):
import pandas as pd
url_Chelsea = "https://en.wikipedia.org/wiki/List_of_Chelsea_F.C._seasons"
df_Chelsea=pd.read_html(url_Chelsea)[2]
df_Chelsea
getting the error message (end of message):
/opt/conda/lib/python3.6/site-packages/pandas/compat/__init__.py in raise_with_traceback(exc, traceback)
338 if traceback == Ellipsis:
339 _, _, traceback = sys.exc_info()
--> 340 raise exc.with_traceback(traceback)
341 else:
342 # this version of raise is a syntax error in Python 3
URLError: <urlopen error Tunnel connection failed: 403 Forbidden>
Try this :
import pandas as pd
import requests
url_Chelsea = "https://en.wikipedia.org/wiki/List_of_Chelsea_F.C._seasons"
proxyDict = {
'http' : "add http proxy",
'https' : "add https proxy"
}
requests.get(url_Chelsea , proxies=proxyDict)
df_Chelsea=pd.read_html(page)[2]
print(df_Chelsea)
For more information about proxies visit here
Related
I installed python package MLRun correctly, but I got in jupyter this error
---------------------------------------------------------------------------
HTTPError Traceback (most recent call last)
/opt/conda/lib/python3.8/site-packages/mlrun/errors.py in raise_for_status(response, message)
75 try:
---> 76 response.raise_for_status()
77 except requests.HTTPError as exc:
/opt/conda/lib/python3.8/site-packages/requests/models.py in raise_for_status(self)
942 if http_error_msg:
--> 943 raise HTTPError(http_error_msg, response=self)
944
HTTPError: 404 Client Error: Not Found for url: https://mlrun-api.default-tenant.app.iguazio.prod//api/v1/client-spec
...
/opt/conda/lib/python3.8/site-packages/mlrun/errors.py in raise_for_status(response, message)
80 error_message = f"{str(exc)}: {message}"
81 try:
---> 82 raise STATUS_ERRORS[response.status_code](
83 error_message, response=response
84 ) from exc
MLRunNotFoundError: 404 Client Error: Not Found for url: https://mlrun-api.default-tenant.app.iguazio.prod//api/v1/client-spec: details: Not Found
based on this source code in python:
%pip install mlrun scikit-learn~=1.0
import mlrun
...
Do you see issues?
BTW: I installed relevant MLRun version (the same as on server side). I modified file mlrun.env and added values for these variables MLRUN_DBPATH, V3IO_USERNAME, V3IO_ACCESS_KEY
Issue
I got it, the problem is in invalid url, see error message Not Found for url: https://mlrun-api.default-tenant.app.iguazio.prod//api/v1/client-spec.
You can see double // and it is the issue, variable MLRUN_DB contains this url 'https://mlrun-api.default-tenant.app.iguazio.prod/'.
Solution
You have to remove end / in MLRUN_DB and final value will be MLRUN_DB=https://mlrun-api.default-tenant.app.iguazio.prod
Now it works.
Until the other day I was able to read files using the dropbox API, but now I get an authentication error.
!pip install dropbox
import dropbox
import time
dbx = dropbox.Dropbox(<Access Token>)
dir = <folder_path>
lists = []
def __get_files_recursive(res):
for entry in res.entries:
##print(list(entry.path_display.split(",")))
lists.append(entry.path_display.split(","))
##print(lists)
print(entry.path_display)
if (res.has_more):
res2 = dbx.files_list_folder_continue(res.cursor)
__get_files_recursive(res2)
res = dbx.files_list_folder(dir, recursive=True)
__get_files_recursive(res)
Error Code was as follows
---------------------------------------------------------------------------
BadInputException Traceback (most recent call last)
<ipython-input-64-f64dcbce5290> in <module>()
12 __get_files_recursive(res2)
13
---> 14 res = dbx.files_list_folder(dir, recursive=True)
15 __get_files_recursive(res)
3 frames
/usr/local/lib/python3.7/dist-packages/dropbox/dropbox_client.py in request_json_string(self, host, func_name, route_style, request_json_arg, auth_type, request_binary, timeout)
562 pass
563 else:
--> 564 raise BadInputException('Unhandled auth type: {}'.format(auth_type))
565
566 # The contents of the body of the HTTP request
BadInputException: Unhandled auth type: app, user
If you know how to solve this problem, please let me know.
I am attempting to translate a list of tweets with the following sample code:
from google_trans_new import google_translator
translator = google_translator()
translate_text = translator.translate('สวัสดีจีน', lang_src='th',lang_tgt='en')
print(translate_text)
I keep running into the following long error when I run the code:
HTTPError Traceback (most recent call last)
~\anaconda3\lib\site-packages\google_trans_new\google_trans_new.py in translate(self, text, lang_tgt, lang_src, pronounce)
188 raise e
--> 189 r.raise_for_status()
190 except requests.exceptions.ConnectTimeout as e:
~\anaconda3\lib\site-packages\requests\models.py in raise_for_status(self)
940 if http_error_msg:
--> 941 raise HTTPError(http_error_msg, response=self)
942
HTTPError: 429 Client Error: Too Many Requests for url: https://www.google.com/sorry/index?continue=https://translate.google.cn/_/TranslateWebserverUi/data/batchexecute&q=EgRrvwCgGLHwuIAGIhkA8aeDS9RXYOujcLlE7r1EY3pCFB3PU57xMgFy
During handling of the above exception, another exception occurred:
google_new_transError Traceback (most recent call last)
<ipython-input-1-e0a80cf9e6cc> in <module>
1 from google_trans_new import google_translator
2 translator = google_translator()
----> 3 translate_text = translator.translate('สวัสดีจีน', lang_src='th',lang_tgt='en')
4 print(translate_text)
5 #output: Hello china
~\anaconda3\lib\site-packages\google_trans_new\google_trans_new.py in translate(self, text, lang_tgt, lang_src, pronounce)
192 except requests.exceptions.HTTPError as e:
193 # Request successful, bad response
--> 194 raise google_new_transError(tts=self, response=r)
195 except requests.exceptions.RequestException as e:
196 # Request failed
google_new_transError: 429 (Too Many Requests) from TTS API. Probable cause: Unknown
Is this because I have used the translator too frequently? When will it reset so I can continue my work?
google_trans_new is an unofficial library using the web API of translate.google.com and also is not associated with Google.
It is crawling the translate web page, which is why you eventually received a 429 error message which is the HTTP 429 Too Many Request status code.
These kind of unofficial libraries are unstable and will eventually get blocked.
To get a stable application you should use the official library which calls the Cloud Translation API.
The Cloud Translation API has quotas but it takes care of handling these errors with retries using exponential backoff.
When I ran the portion of code below I get a JSON error message. I am trying to access a Jira project from Python but it keeps failing.
File "C:\FAST\anaconda\python36\win64\431\Lib\json\decoder.py", line 357, in raw_decode
raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 7 column 1 (char 6)
I have followed the examples provided by Python and Jira, but I cannot make the code work.
from jira.client import JIRA
import json
options = {
'server': 'https://some.server.net/jira12/projects/XXXX',
}
USERNAME=input("Enter your username: ")
PASSWORD=input("Enter your password: ")
jira = JIRA(options, basic_auth=(USERNAME, PASSWORD))
issue = jira.issue('XXXX-260', expand='changelog')
I happened to help a colleague solve a similar issue.
I would suggest to try changing your server url from
options = {'server': 'https://some.server.net/jira12/projects/XXXX', }
to
options = {'server': 'https://some.server.net/', }
I did it like this in a project:
JIRA(basic_auth=(self.username, self.password), options={'server': 'URL'})
I am new to python and I have been making codes to scrap twitter data on python.
Below are my codes:
import csv
import json
import twitter_oauth
import sys
sys.path.append("/Users/jdschnieder/Documents/Modules")
print sys.path
#gain authorization to twitter
consumer_key = 'xdbX1g21REs0MPxofJPcFw'
consumer_secret = 'c9S9YI6G3GIdjkg67ecBaCXSJDlGw4sybTv1ccnkrA'
get_oauth_obj = twitter_oauth.GetOauth(consumer_key, consumer_secret)
get_oauth_obj.get_oauth()
the error occurs at the line:
get_oauth_obj.get_oauth()
the error message is as follows:
---------------------------------------------------------------------------
Exception Traceback (most recent call last)
<ipython-input-36-5d124f99deb6> in <module>()
--> 1 get_oauth_obj.get_oauth()
/Users/jdschnieder/anaconda/python.app/Contents/lib/python2.7/site-packages/
twitter_oauth-0.2.0-py2.7.egg/twitter_oauth.pyc in get_oauth(self)
95 resp, content = client.request(_REQUEST_TOKEN_URL, "GET")
96 if resp['status'] != '200':
-> 97 raise Exception('Invalid response %s' % resp['status'])
98
99 request_token = dict(self._parse_qsl(content))
Exception: Invalid response 401
why is this error occurring, and what are possible solutions to the error?
thank you,
It looks like the Twitter library you're using does not support Twitter API v1.1. Instead of twitter_oauth, use one of the Python libraries listed here. For example, you can use Tweepy, following the documentation for OAuth Authentication