Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

requests gspread library fails to pip install because dependency requests library missing #317

Closed
mosesmc52 opened this issue Oct 19, 2015 · 6 comments
Labels

Comments

@mosesmc52
Copy link

Hi,

I regularly install this library in to a virtual environment using the pip install command. After last Friday, the gspread library fails to install because it didn't pre-install the dependent requests library. Here is the stack trace error I see. This is the command line argument I use to install the gspread library.

pip install https://github.com/burnash/gspread/archive/master.zip

Moses

File "/var/folders/dl/jt5zsvy91gx3g8_pflz9c5680000gp/T/pip-zaKdHf-build/setup.py", line 6, in

import gspread

File "gspread/init.py", line 21, in

from .client import Client, login, authorize

File "gspread/client.py", line 19, in

from .httpsession import HTTPSession, HTTPError

File "gspread/httpsession.py", line 11, in

import requests

ImportError: No module named requests


Cleaning up...
Command python setup.py egg_info failed with error code 1 in /var/folders/dl/jt5zsvy91gx3g8_pflz9c5680000gp/T/pip-zaKdHf-build
Storing debug log for failure in /Users/user/.pip/pip.log

@msuozzo msuozzo added the Bug label Oct 20, 2015
@msuozzo
Copy link
Collaborator

msuozzo commented Oct 20, 2015

This is a consequence of the way in which the version string is centralized in gspread's __init__.py file. setup.py wants to import gspread to get the __version__ string for the module but __init__.py also imports all of the modules' exports (e.g. from .client import Client, login, authorize). This import statement runs import requests which has not yet been triggered by the setup() function later in setup.py.

A likely consequence of this is that gspread cannot be imported from setup.py. This means the versions string will need to live in two places (not the worst thing in the world).

@burnash: Do you have a preference as to how this should be handled?
Unfortunately, this is one of the many costs of adding dependencies :-(

@msuozzo
Copy link
Collaborator

msuozzo commented Oct 20, 2015

Never mind. requests to the rescue:

version = ''
with open('requests/__init__.py', 'r') as fd:
  version = re.search(r'^__version__\s*=\s*[\'"]([^\'"]*)[\'"]',
                       fd.read(), re.MULTILINE).group(1)

@msuozzo
Copy link
Collaborator

msuozzo commented Oct 20, 2015

Thanks a ton for reporting this @mosesmc52!

@mosesmc52
Copy link
Author

Thanks for responding promptly. Anytime, Gspread is a great tool.

@burnash
Copy link
Owner

burnash commented Oct 20, 2015

@mosesmc52 many thanks for spotting this.
@msuozzo Totally agree with this. Many other projects handle the version string in a similar way including Flask.

Talking about versions, I believe it's time to bump up the gspread's minor version to 3 and release the lib on the PyPI.

@ilprincipecolo
Copy link

OK. Solution is found. Need to point full path:

import sys
sys.path.append('/home/usename/.local/lib/python2.7/site-packages/')
import gspread

from https://www.pythonanywhere.com/forums/topic/13265/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants