I get an error when I'm trying to import graphene into a simple project:
Error: While importing "stronk.app", an ImportError was raised:
Traceback (most recent call last):
File "/home/markw/.local/lib/python3.6/site-packages/flask/cli.py", line 240, in locate_app
__import__(module_name)
File "/home/markw/Desktop/REPO/stronk-backend/stronk/__init__.py", line 7, in <module>
from graphene import ObjectType, String, Schema
File "/home/markw/.local/lib/python3.6/site-packages/graphene/__init__.py", line 3, in <module>
from .types import (
File "/home/markw/.local/lib/python3.6/site-packages/graphene/types/__init__.py", line 2, in <module>
from graphql import ResolveInfo
ImportError: cannot import name 'ResolveInfo'
I checked other similar issues in the graphene-django repo (https://github.com/graphql-python/graphene-django/issues/737), but I don't have a graphql folder in the root of my project. Any advice would be helpful :)
here's my requirements.txt
Flask==1.1.1
Flask-SQLAlchemy==2.4.1
SQLAlchemy==1.3.12
Flask-Migrate==2.5.2
psycopg2-binary==2.8.4
python-dotenv==0.11.0
firebase-admin==4.1.0
graphene==2.0.0
I've tried other versions of graphene, but the issue persists
here's the output of my pip3 freeze
alembic==1.4.2
aniso8601==7.0.0
appdirs==1.4.3
apturl==0.5.2
asn1crypto==0.24.0
astroid==2.3.3
attrs==19.3.0
autopep8==1.5
bcrypt==3.1.7
blinker==1.4
Brlapi==0.6.6
CacheControl==0.12.6
cached-property==1.5.1
cachetools==4.1.0
certifi==2020.4.5.1
cffi==1.13.2
chardet==3.0.4
click==7.1.2
colorama==0.3.7
command-not-found==0.3
cryptography==2.8
cupshelpers==1.0
defer==1.0.6
distlib==0.3.0
distro==1.0.1
distro-info===0.18ubuntu0.18.04.1
docker==4.1.0
docker-compose==1.25.2
dockerpty==0.4.1
docopt==0.6.2
evdev==0.7.0
filelock==3.0.12
firebase-admin==4.1.0
Flask==1.1.1
Flask-GraphQL==2.0.1
Flask-Migrate==2.5.2
Flask-SQLAlchemy==2.4.1
google-api-core==1.17.0
google-api-python-client==1.8.2
google-auth==1.14.1
google-auth-httplib2==0.0.3
google-cloud-core==1.3.0
google-cloud-firestore==1.6.2
google-cloud-storage==1.28.0
google-resumable-media==0.5.0
googleapis-common-protos==1.51.0
graphene==2.1.8
graphql-core==3.1.0
graphql-relay==3.0.0
graphql-server-core==1.2.0
grpcio==1.28.1
Guake==3.0.5
httplib2==0.17.3
idna==2.9
importlib-metadata==1.4.0
importlib-resources==1.0.2
isort==4.3.21
itsdangerous==1.1.0
Jinja2==2.11.2
jsonschema==3.2.0
keyring==10.6.0
keyrings.alt==3.0
language-selector==0.1
launchpadlib==1.10.6
lazr.restfulclient==0.13.5
lazr.uri==1.0.3
lazy-object-proxy==1.4.3
louis==3.5.0
lutris==0.5.5
macaroonbakery==1.1.3
Mako==1.1.2
MarkupSafe==1.1.1
mccabe==0.6.1
more-itertools==8.1.0
msgpack==1.0.0
netifaces==0.10.4
oauth==1.0.1
olefile==0.45.1
paramiko==2.7.1
pbr==3.1.1
pexpect==4.2.1
Pillow==5.1.0
promise==2.3
protobuf==3.11.3
psutil==5.4.2
psycopg2-binary==2.8.4
pyasn1==0.4.8
pyasn1-modules==0.2.8
pycairo==1.16.2
PyChromecast==0.8.1
pycodestyle==2.5.0
pycparser==2.19
pycrypto==2.6.1
pycups==1.9.73
pygobject==3.26.1
pyinotify==0.9.6
pylint==2.4.4
pymacaroons==0.13.0
PyNaCl==1.3.0
pyOpenSSL==17.5.0
pyRFC3339==1.0
pyrsistent==0.15.7
python-apt==1.6.5+ubuntu0.2
python-dateutil==2.8.1
python-debian==0.1.32
python-distutils-extra==2.39
python-dotenv==0.11.0
python-editor==1.0.4
python-Levenshtein==0.12.0
pytz==2020.1
pyxattr==0.6.0
pyxdg==0.25
PyYAML==5.3
reportlab==3.4.0
requests==2.23.0
requests-unixsocket==0.1.5
rsa==4.0
Rx==1.6.1
SecretStorage==2.3.1
setproctitle==1.1.10
simplejson==3.13.2
six==1.14.0
SQLAlchemy==1.3.12
system-service==0.3
systemd-python==234
texttable==1.6.2
typed-ast==1.4.1
ubuntu-drivers-common==0.0.0
ufw==0.36
ulauncher==5.4.0
unattended-upgrades==0.1
uritemplate==3.0.1
urllib3==1.25.9
usb-creator==0.3.3
virtualenv==20.0.2
wadllib==1.3.2
websocket-client==0.57.0
Werkzeug==1.0.1
wrapt==1.11.2
xkit==0.0.0
youtube-dl==2018.3.14
zeroconf==0.19.1
zipp==2.0.0
zope.interface==4.3.2
Something to check for is that you don't have a graphql.py file lying around in your project, that's the usual culprit.
@13ABEL make sure you are using the latest graphene version (2.1.8). Also it looks like somehow you've installed graphql-core v3 which not compatible with graphene v2.
@SmileyChris: I just checked and there isn't one so maybe it's the other issue?
@jkimbo: thanks for the suggestion, I've tried 2.1.8 and it's yielded the same issue. Should I just uninstall graphql-core and let pip resolve the graphql core dependency from graphene?
Yes I would recommend just installing everything from scratch to make sure you get the right versions. Or use something like pip-tools to pin all your dependencies.
@jkimbo cool, thanks I'll take a look! I also realized I wasn't using venv earlier and switching to venv resolved the issue!
I'm just curious about why the I still get the issue if I'm not using venv:
If I make the change from graphql-core==3.x.x. to graphql-core==2.3.1 and install the dependencies without using venv, running the app will yield a different error:
Traceback (most recent call last):
File "/home/markw/.local/lib/python3.6/site-packages/flask/cli.py", line 240, in locate_app
__import__(module_name)
File "/home/markw/Desktop/REPO/stronk-backend/stronk/__init__.py", line 7, in <module>
from graphene import ObjectType, String, Schema
File "/home/markw/.local/lib/python3.6/site-packages/graphene/__init__.py", line 33, in <module>
from .relay import (
File "/home/markw/.local/lib/python3.6/site-packages/graphene/relay/__init__.py", line 1, in <module>
from .node import Node, is_node, GlobalID
File "/home/markw/.local/lib/python3.6/site-packages/graphene/relay/node.py", line 5, in <module>
from graphql_relay import from_global_id, to_global_id
File "/home/markw/.local/lib/python3.6/site-packages/graphql_relay/__init__.py", line 1, in <module>
from .connection.connection import (
File "/home/markw/.local/lib/python3.6/site-packages/graphql_relay/connection/connection.py", line 13, in <module>
from ..utils import resolve_maybe_thunk
ImportError: cannot import name 'resolve_maybe_thunk'
Thanks for the help :)
graphql-relay needs to be v2.0.1. These restrictions are all setup correctly in the various graphql packages it's just that pip doesn't enforce them once they have been installed (potentially incorrectly). Using a clean venv is a good way of making sure that you are only installing the packages that you need.
Thanks for the info and help :) I'll close the issue!