當嘗試使用谷歌API客戶端,我已經得到了一個錯誤,許多人都得到了:使用六個比1.4.1更高版本上運行的python腳本
AttributeError: 'Module_six_moves_urllib_parse' object has no attribute 'urlencode'
我都想盡在StackOverflow的,GitHub上,和其他地方,包括髮現溶液:
1)從this thread,改變在實際的代碼的路徑:
import sys
sys.path.insert(1, '/Library/Python/2.7/site-packages')
2)從this thread,改變在.bashrc中和的.bash_profile文件Python路徑:
pip show six | grep "Location:" | cut -d " " -f2
export PYTHONPATH=$PYTHONPATH:<pip_install_path>
source ~/.bashrc
3)和從this thread,降級我的谷歌API客戶端1.3.2(或至少試圖)。
我是編程新手,所以這可能是一個基本問題,但我花了好幾天的時間來嘗試排除故障並無濟於事。看起來無論我做什麼,六個舊的1.4版本都在使用。任何幫助你可以提供將非常感激!
編輯:完整回溯:
Traceback (most recent call last):
File "/Users/zachgoldfine/PycharmProjects/FirstTry/GetAroundRentalSpreadsheetRead.py", line 71, in <module>
spreadsheetId=spreadsheetId, range=rangeName1).execute()
File "/Library/Python/2.7/site-packages/oauth2client/util.py", line 129, in positional_wrapper
return wrapped(*args, **kwargs)
File "/Library/Python/2.7/site-packages/googleapiclient/http.py", line 836, in execute
method=str(self.method), body=self.body, headers=self.headers)
File "/Library/Python/2.7/site-packages/googleapiclient/http.py", line 162, in _retry_request
resp, content = http.request(uri, method, *args, **kwargs)
File "/Library/Python/2.7/site-packages/oauth2client/transport.py", line 186, in new_request
credentials._refresh(orig_request_method)
File "/Library/Python/2.7/site-packages/oauth2client/client.py", line 761, in _refresh
self._do_refresh_request(http)
File "/Library/Python/2.7/site-packages/oauth2client/client.py", line 774, in _do_refresh_request
body = self._generate_refresh_request_body()
File "/Library/Python/2.7/site-packages/oauth2client/client.py", line 716, in _generate_refresh_request_body
body = urllib.parse.urlencode({
AttributeError: 'Module_six_moves_urllib_parse' object has no attribute 'urlencode'
,您可以包括完整的追蹤,所以我們可以從文件(S)的錯誤起源看? – Evert
@Evert添加了完整的追溯 –
我在追蹤中看到提及pycharm。你是通過pycharm運行的東西嗎?這可能是一個問題。我對pycharm並不熟悉,但是如果可以避免它並嘗試從命令行運行相關腳本,那可能有助於縮小問題原因。 – Evert