Closed GitMew closed 4 years ago
Can you provide a more detailed stack traceback? Also please post the name of the Python script you're running.
As I said, that's literally all, both in regards to the traceback, as for the script (named "Chatclient.py").
Even in a script with the single line import gspread
, it causes an ImportError.
The traceback, in full (if that'd make any difference), is:
Traceback (most recent call last):
File "Chatclient.py", line 1, in <module>
import gspread
File "C:\Users\[user]\AppData\Local\Python\Python36-32\lib\site-packages\gspread-2.0.0-py3.6.egg\gspread\__init__.py", line 28, in <module>
ImportError: cannot import name 'v4'
Can you list the contents of C:\Users\[user]\AppData\Local\Python\Python36-32\lib\site-packages\gspread-2.0.0-py3.6.egg\gspread
?
I'm getting same error:
Traceback (most recent call last):
File "test.py", line 1, in
bdist.linux-armv6l is empty in my filesystem
@hjbct44 what's your OS?
Raspbian on Raspberry Pi
PRETTY_NAME="Raspbian GNU/Linux 8 (jessie)" NAME="Raspbian GNU/Linux" VERSION_ID="8" VERSION="8 (jessie)" ID=raspbian ID_LIKE=debian HOME_URL="http://www.raspbian.org/" SUPPORT_URL="http://www.raspbian.org/RaspbianForums" BUG_REPORT_URL="http://www.raspbian.org/RaspbianBugs"
@hjbct44 what was your installation method? (e.g pip, etc.)
I just upgraded today pip install gspread --upgrade
It was working fine before that.
I just reinstalled using pip install gspread==2.0.0 and looks like it is working (i'm not getting import error).
Like you asked, here are contents of the gspread directory inside the .egg:
And, inside that pycache:
@hjbct44 thanks for the information
@GitMew for some reason it looks like you still have an older version. Can you also try to re-install it as @hjbct44 did?
I am also trying to use gspread on a Raspberry Pi running Stretch. I am getting the same error message:
Traceback (most recent call last):
File "/home/pi/Weather/temp-and-humidity/temperature-and-humidity-to-csv-logger.py", line 15, in
I tried to re-install with pip install gspread==2.0.0 but I still get this error.
Tried to re-install using the procedure listed below, but again, to no avail, sadly.
git clone https://github.com/burnash/gspread/
cd gspread
py setup.py install
Note that it does indeed say it's "gspread-2.0.0-py3.6.egg", which should be the most recent version.
Hi guys, I "fix it" by removing the gspread-2.0.0-py3.5.egg file and then installing with pip install gspread==2.0.0... I really don't have ANY idea of what I have done, just pure luck but its appears to work fine now.
I'm just getting back to looking at my code for V2.0. Does the new version require different authentication ?
@hjbct44 You need to update your scope
so it looks like this:
scope = ['https://spreadsheets.google.com/feeds',
'https://www.googleapis.com/auth/drive']
See https://github.com/burnash/gspread/issues/513 for the details.
I changed credentials to:
credentials = SignedJwtAssertionCredentials(json_key['client_email'], json_key['private_key'], ['https://spreadsheets.google.com/feeds','https://www.googleapis.com/auth/drive'])
But I get this error:
Unable to login and get spreadsheet. Check OAuth credentials, spreadsheet name, and make sure spreadsheet is shared to the client_email address in the OAuth .j son file! ('Google sheet login failed with error:', APIError(u'{\n "error": {\n "code" : 403,\n "message": "Google Sheets API has not been used in project porkpi-12 07 before or it is disabled. Enable it by visiting https://console.developers.go ogle.com/apis/api/sheets.googleapis.com/overview?project=REDACTED then retry. If you enabled this API recently, wait a few minutes for the action to propagat e to our systems and retry.",\n "status": "PERMISSION_DENIED",\n "details" : [\n {\n "@type": "type.googleapis.com/google.rpc.Help",\n " links": [\n {\n "description": "Google developers console AP I activation",\n "url": "https://console.developers.google.com/apis/a pi/sheets.googleapis.com/overview?project=REDACTED"\n }\n ]\n }\n ]\n }\n}\n',)) Google sheet login failed
Fixed - had to re-enable API on Google.
Thanks for all your help and for gspread - great tool!
I don't know if I'm understanding this the wrong way, but it seems to me like @hjbct44 hijacked this thread. The issues described have nothing to do with the ImportError, and @burnash is yet to provide a solution to said error (which multiple people have reported encountering, too ...).
Wow - I think I contributed to the solution here. There are 2 proposals above which both propose fixes that work for myself and Laikos38.
You may want to consider your tone if you want help going forward.
Good luck. Out.
I looked at my code, and I have the scope as stated, but I cannot get to even test this. I also uninstalled and reinstalled per the suggestion above. However, I still cannot get past the import problem:
Traceback (most recent call last): File "/home/pi/Weather/temp-and-humidity/temperature-and-humidity-to-csv-logger.py", line 15, in import gspread File "/usr/local/lib/python3.5/dist-packages/gspread-2.0.0-py3.5.egg/gspread/init.py", line 28, in from . import v4 ImportError: cannot import name 'v4'
Can you suggest how I might get past the "import V4" error?
@hjbct44, no need to be so vile - it's pretty surreal to have someone tell me to watch my tone on a code-sharing platform, with me having used the politest and concise way of formulating things as is possible. I'm merely pointing out that you've shifted the topic of this thread (which is the truth, no point in denying: it's literally verifiable above ...), and that we haven't gotten any working answers yet.
I've already pointed out (and provided as much info as I could or was asked) that none of the proposed answers have worked so far (verifiable above as well). Thereby, there're people like @hwdornbush who are experiencing the same troubles, with none of the mentioned solutions actually working. It'd make sense for me to ask for a working solution if none have worked so far, would it not?
I'm not here to start a flame war - I'm here to ask for viable answers to a library that's not installing properly (hence this thread in the first place). For that matter, I don't think anyone should care about wording, but rather about the amount of information given and an eventual positive outcome for everyone (again, hence this thread).
@GitMew @hwdornbush can you try upgrade to version 3.0.0 to see if this resolves the issue?
I get an error: $ pip install gspread --upgrade Collecting gspread Exception: Traceback (most recent call last): File "/usr/lib/python2.7/dist-packages/pip/basecommand.py", line 215, in main status = self.run(options, args) File "/usr/lib/python2.7/dist-packages/pip/commands/install.py", line 353, in run wb.build(autobuilding=True) File "/usr/lib/python2.7/dist-packages/pip/wheel.py", line 749, in build self.requirement_set.prepare_files(self.finder) File "/usr/lib/python2.7/dist-packages/pip/req/req_set.py", line 380, in prepare_files ignore_dependencies=self.ignore_dependencies)) File "/usr/lib/python2.7/dist-packages/pip/req/req_set.py", line 554, in _prepare_file require_hashes File "/usr/lib/python2.7/dist-packages/pip/req/req_install.py", line 278, in populate_link self.link = finder.find_requirement(self, upgrade) File "/usr/lib/python2.7/dist-packages/pip/index.py", line 465, in find_requirement all_candidates = self.find_all_candidates(req.name) File "/usr/lib/python2.7/dist-packages/pip/index.py", line 423, in find_all_candidates for page in self._get_pages(url_locations, project_name): File "/usr/lib/python2.7/dist-packages/pip/index.py", line 568, in _get_pages page = self._get_page(location) File "/usr/lib/python2.7/dist-packages/pip/index.py", line 683, in _get_page return HTMLPage.get_page(link, session=self.session) File "/usr/lib/python2.7/dist-packages/pip/index.py", line 792, in get_page "Cache-Control": "max-age=600", File "/usr/share/python-wheels/requests-2.12.4-py2.py3-none-any.whl/requests/sessions.py", line 501, in get return self.request('GET', url, *kwargs) File "/usr/lib/python2.7/dist-packages/pip/download.py", line 386, in request return super(PipSession, self).request(method, url, args, kwargs) File "/usr/share/python-wheels/requests-2.12.4-py2.py3-none-any.whl/requests/sessions.py", line 488, in request resp = self.send(prep, send_kwargs) File "/usr/share/python-wheels/requests-2.12.4-py2.py3-none-any.whl/requests/sessions.py", line 609, in send r = adapter.send(request, kwargs) File "/usr/share/python-wheels/CacheControl-0.11.7-py2.py3-none-any.whl/cachecontrol/adapter.py", line 47, in send resp = super(CacheControlAdapter, self).send(request, kw) File "/usr/share/python-wheels/requests-2.12.4-py2.py3-none-any.whl/requests/adapters.py", line 423, in send timeout=timeout File "/usr/share/python-wheels/urllib3-1.19.1-py2.py3-none-any.whl/urllib3/connectionpool.py", line 643, in urlopen _stacktrace=sys.exc_info()[2]) File "/usr/share/python-wheels/urllib3-1.19.1-py2.py3-none-any.whl/urllib3/util/retry.py", line 315, in increment total -= 1 TypeError: unsupported operand type(s) for -=: 'Retry' and 'int' pi@rpiwtest:~ $
If I try using PIP3, I also get an error:
$ pip3 install gspread --upgrade Collecting gspread Exception: Traceback (most recent call last): File "/usr/share/python-wheels/urllib3-1.19.1-py2.py3-none-any.whl/urllib3/contrib/pyopenssl.py", line 417, in wrap_socket cnx.do_handshake() File "/usr/lib/python3/dist-packages/OpenSSL/SSL.py", line 1426, in do_handshake self._raise_ssl_error(self._ssl, result) File "/usr/lib/python3/dist-packages/OpenSSL/SSL.py", line 1149, in _raise_ssl_error raise WantReadError() OpenSSL.SSL.WantReadError
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File "/usr/share/python-wheels/urllib3-1.19.1-py2.py3-none-any.whl/urllib3/connectionpool.py", line 350, in _make_request self._validate_conn(conn) File "/usr/share/python-wheels/urllib3-1.19.1-py2.py3-none-any.whl/urllib3/connectionpool.py", line 837, in _validate_conn conn.connect() File "/usr/share/python-wheels/urllib3-1.19.1-py2.py3-none-any.whl/urllib3/connection.py", line 323, in connect sslcontext=context) File "/usr/share/python-wheels/urllib3-1.19.1-py2.py3-none-any.whl/urllib3/util/ssl.py", line 324, in ssl_wrap_socket return context.wrap_socket(sock, server_hostname=server_hostname) File "/usr/share/python-wheels/urllib3-1.19.1-py2.py3-none-any.whl/urllib3/contrib/pyopenssl.py", line 421, in wrap_socket raise timeout('select timed out') socket.timeout: select timed out
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File "/usr/share/python-wheels/urllib3-1.19.1-py2.py3-none-any.whl/urllib3/connectionpool.py", line 594, in urlopen chunked=chunked) File "/usr/share/python-wheels/urllib3-1.19.1-py2.py3-none-any.whl/urllib3/connectionpool.py", line 353, in _make_request self._raise_timeout(err=e, url=url, timeout_value=conn.timeout) File "/usr/share/python-wheels/urllib3-1.19.1-py2.py3-none-any.whl/urllib3/connectionpool.py", line 313, in _raise_timeout raise ReadTimeoutError(self, url, "Read timed out. (read timeout=%s)" % timeout_value) requests.packages.urllib3.exceptions.ReadTimeoutError: HTTPSConnectionPool(host='www.piwheels.org', port=443): Read timed out. (read timeout=15)
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File "/usr/lib/python3/dist-packages/pip/basecommand.py", line 215, in main status = self.run(options, args) File "/usr/lib/python3/dist-packages/pip/commands/install.py", line 353, in run wb.build(autobuilding=True) File "/usr/lib/python3/dist-packages/pip/wheel.py", line 749, in build self.requirement_set.prepare_files(self.finder) File "/usr/lib/python3/dist-packages/pip/req/req_set.py", line 380, in prepare_files ignore_dependencies=self.ignore_dependencies)) File "/usr/lib/python3/dist-packages/pip/req/req_set.py", line 554, in _prepare_file require_hashes File "/usr/lib/python3/dist-packages/pip/req/req_install.py", line 278, in populate_link self.link = finder.find_requirement(self, upgrade) File "/usr/lib/python3/dist-packages/pip/index.py", line 465, in find_requirement all_candidates = self.find_all_candidates(req.name) File "/usr/lib/python3/dist-packages/pip/index.py", line 423, in find_all_candidates for page in self._get_pages(url_locations, project_name): File "/usr/lib/python3/dist-packages/pip/index.py", line 568, in _get_pages page = self._get_page(location) File "/usr/lib/python3/dist-packages/pip/index.py", line 683, in _get_page return HTMLPage.get_page(link, session=self.session) File "/usr/lib/python3/dist-packages/pip/index.py", line 792, in get_page "Cache-Control": "max-age=600", File "/usr/share/python-wheels/requests-2.12.4-py2.py3-none-any.whl/requests/sessions.py", line 501, in get return self.request('GET', url, *kwargs) File "/usr/lib/python3/dist-packages/pip/download.py", line 386, in request return super(PipSession, self).request(method, url, args, kwargs) File "/usr/share/python-wheels/requests-2.12.4-py2.py3-none-any.whl/requests/sessions.py", line 488, in request resp = self.send(prep, send_kwargs) File "/usr/share/python-wheels/requests-2.12.4-py2.py3-none-any.whl/requests/sessions.py", line 609, in send r = adapter.send(request, kwargs) File "/usr/share/python-wheels/CacheControl-0.11.7-py2.py3-none-any.whl/cachecontrol/adapter.py", line 47, in send resp = super(CacheControlAdapter, self).send(request, kw) File "/usr/share/python-wheels/requests-2.12.4-py2.py3-none-any.whl/requests/adapters.py", line 423, in send timeout=timeout File "/usr/share/python-wheels/urllib3-1.19.1-py2.py3-none-any.whl/urllib3/connectionpool.py", line 643, in urlopen _stacktrace=sys.exc_info()[2]) File "/usr/share/python-wheels/urllib3-1.19.1-py2.py3-none-any.whl/urllib3/util/retry.py", line 315, in increment total -= 1 TypeError: unsupported operand type(s) for -=: 'Retry' and 'int'
@hwdornbush it doesn't look like it's related to gspread. More likely it's a pip / network problem.
Take a look at TypeError: unsupported operand type(s) for -=: 'Retry' and 'int'
on SO.
I uninstalled and reinstalled pip, and then gspread==3.0.0. I had some trouble with Thonny (the IDE I use on RaspberyPi) so I rebooted. Thonny disappeared, so I reinstalled it. Then I ran my program and got a different error message:
Traceback (most recent call last):
File "/home/pi/Weather/temp-and-humidity/temperature-and-humidity-to-csv-logger-gspread.py", line 16, in
I had the same issue as @hjbct44 (who I suspect was off track with the issue initially raised here but helped solve my problem) on an upgrade from 0.6.2 to 3.0.1 and got:
Google Sheets API error gspread.exceptions.APIError: { "error": { "code": 403, "message": "Google Sheets API has not been used in project XXX before or it is disabled. Enable it by visiting https://console.developers.google.com/apis/api/sheets.googleapis.com/overview?project=XXX
which didn't work until I disabled and renabled Google Drive API which then allowed me to successfully enable Google Sheets API.
Could this be added to the instructions for upgrading an existing project previously using the old Google API?
So, I'm trying to import the gspread library, but after freezing for a few seconds, the console spits out an error in doing so.
Environment info
Operating System: Windows 7 Python version: 3.6 gspread version: 2.0.0
Steps to reproduce
import gspread
Stack trace or other output that would be helpful
File "C:\Users\[user]\AppData\Local\Python\Python36-32\lib\site-packages\gspread-2.0.0-py3.6.egg\gspread\__init__.py", line 28, in <module> ImportError: cannot import name 'v4'