graphene icon indicating copy to clipboard operation
graphene copied to clipboard

ModuleNotFoundError: No module named 'graphql'

Open dsw0214 opened this issue 7 years ago • 7 comments

The Python virtual environment use created with virtualenv ,python version is

#python --version
Python 3.7.3

When I execute the following commands:

#py.test graphene/relay/ 

The following error occurred:

Hint: make sure your test modules/packages have valid Python names.
Traceback:
graphene/__init__.py:3: in <module>
    from .types import (
graphene/types/__init__.py:2: in <module>
    from graphql import GraphQLResolveInfo as ResolveInfo
E   ModuleNotFoundError: No module named 'graphql'

But when I execute the following commands install graphql extension,have following error:

# pip install graphql
Complete output (10 lines):
  running bdist_wheel
  running build
  running build_py
  creating build
  creating build/lib.macosx-10.7-x86_64-3.7
  creating build/lib.macosx-10.7-x86_64-3.7/graphql
  copying graphql/__init__.py -> build/lib.macosx-10.7-x86_64-3.7/graphql
  running build_ext
  building 'graphql_ext' extension
  error: unknown file type '.pyx' (from 'graphql/graphql_ext.pyx')
  ----------------------------------------
  ERROR: Failed building wheel for graphql

I wonder if you have encountered this problem.

dsw0214 avatar Aug 29 '19 06:08 dsw0214

Try: pip install pip --upgrade

pip install setuptools --upgrade

manesioz avatar Aug 29 '19 13:08 manesioz

Try: pip install pip --upgrade

pip install setuptools --upgrade

Thank you for your reply. I tried your operation, but now there are other new error. when I execute the following commands

# py.test graphene/relay

have new following error:

_______________________________________________________ ERROR collecting graphene/relay/tests/test_connection.py ________________________________________________________
ImportError while importing test module '/Users/shiwei/Documents/python_project/study_graphene_new/graphene/graphene/relay/tests/test_connection.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
graphene/__init__.py:33: in <module>
    from .relay import (
graphene/relay/__init__.py:1: in <module>
    from .node import Node, is_node, GlobalID
graphene/relay/node.py:4: in <module>
    from graphql_relay import from_global_id, to_global_id
../lib/python3.7/site-packages/graphql_relay/__init__.py:16: in <module>
    from .mutation.mutation import (
../lib/python3.7/site-packages/graphql_relay/mutation/mutation.py:3: in <module>
    from graphql.type import (
E   ImportError: cannot import name 'GraphQLInputObjectField' from 'graphql.type' (/Users/shiwei/Documents/python_project/study_graphene_new/lib/python3.7/site-packages/graphql/type/__init__.py)

I

dsw0214 avatar Aug 30 '19 07:08 dsw0214

@dsw0214 Shell history

14463  git clone https://github.com/graphql-python/graphene.git
14464  cd graphene
14465  python setup.py install
14466  py.test graphene/relay/

Hanaasagi avatar Sep 03 '19 02:09 Hanaasagi

@Hanaasagi Thank you very much for your reply. I tried again, but still not work. My Environmental information is as follows:

#virtualenv --version
15.2.0
#python -V
Python 3.7.3
#System:
macOs Mojave(version:10.14)

dsw0214 avatar Sep 03 '19 10:09 dsw0214

@manesioz @Hanaasagi Thank you again for your reply and help. I tried different platforms and environments, and now it works:

# System: CentOS Linux release 7.2.1511 (Core) 
# virtualenv --version
16.0.0
# python -V 
Python 3.6.9

f780c70-e06b-466e-858b-b34231fccfd7

The problem should be caused by the operating environment.

dsw0214 avatar Sep 03 '19 10:09 dsw0214

I got the same problem, i had a graphql named folder in the root

Fixed with

ajolote-656 avatar Sep 07 '20 06:09 ajolote-656

I got the same error: error: unknown file type '.pyx' (from 'graphql/graphql_ext.pyx')

These commands worked for me to get rid from graphql errors. pip install pip --upgrade pip install setuptools --upgrade pip install gql[all]

nandinichaurasiya avatar Oct 18 '22 07:10 nandinichaurasiya