fabiobatalha / crossrefapi

A python library that implements the Crossref API.
BSD 2-Clause "Simplified" License
265 stars 44 forks source link

ImportError: No module named restful #12

Closed mayurpatil1211 closed 6 years ago

mayurpatil1211 commented 6 years ago

When i am importing crossref.restful, getting error

`from crossref.restful import Works
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "crossref.py", line 1, in <module>
    from crossref.restful import Works
ImportError: No module named restful

`

fabiobatalha commented 6 years ago

@mayurpatil1211

Could you describe your environment?

mayurpatil1211 commented 6 years ago

@fabiobatalha I am using python2.7 . after installing pip install crossref, when i try to import crossref.restful. I am getting that error

fabiobatalha commented 6 years ago

@mayurpatil1211

Just to check. The correct library is crossrefapi not crossref. Are you installing the correct library?

pip install crossrefapi

What version is installed?

mayurpatil1211 commented 6 years ago

@fabiobatalha yeah, crossrefapi==1.2.0 this is the library i have installed.

mayurpatil1211 commented 6 years ago

@fabiobatalha If there is any api apart from this library to get records from crossref, then please let me know.

fabiobatalha commented 6 years ago

@mayurpatil1211

Not sure, but it seems you have a module name conflict. There are any place where I can check your source code?

mayurpatil1211 commented 6 years ago

currently i am executing it on console. and i am just following whatever written in README.md . I'll make another environment and i will check if there is module name conflict then it will get solve.

mayurpatil1211 commented 6 years ago

@fabiobatalha Nope, I tried with different environment too, but same error.

fabiobatalha commented 6 years ago

@mayurpatil1211

I'm not able to emulate your problem.

It is working perfectly well for me.

please run a pip list in your environment and send me the result.

Try to do something like the lines below.

Fabios-MacBook-Pro:~ fabiobatalha$ mkvirtualenv testcrossrefapi
New python executable in /Users/fabiobatalha/.virtualenvs/testcrossrefapi/bin/python
Installing setuptools, pip, wheel...done.
virtualenvwrapper.user_scripts creating /Users/fabiobatalha/.virtualenvs/testcrossrefapi/bin/predeactivate
virtualenvwrapper.user_scripts creating /Users/fabiobatalha/.virtualenvs/testcrossrefapi/bin/postdeactivate
virtualenvwrapper.user_scripts creating /Users/fabiobatalha/.virtualenvs/testcrossrefapi/bin/preactivate
virtualenvwrapper.user_scripts creating /Users/fabiobatalha/.virtualenvs/testcrossrefapi/bin/postactivate
virtualenvwrapper.user_scripts creating /Users/fabiobatalha/.virtualenvs/testcrossrefapi/bin/get_env_details
(testcrossrefapi) Fabios-MacBook-Pro:~ fabiobatalha$ pip install crossrefapi
Collecting crossrefapi
Collecting requests>=2.11.1 (from crossrefapi)
  Using cached requests-2.18.4-py2.py3-none-any.whl
Collecting idna<2.7,>=2.5 (from requests>=2.11.1->crossrefapi)
  Using cached idna-2.6-py2.py3-none-any.whl
Collecting urllib3<1.23,>=1.21.1 (from requests>=2.11.1->crossrefapi)
  Using cached urllib3-1.22-py2.py3-none-any.whl
Collecting certifi>=2017.4.17 (from requests>=2.11.1->crossrefapi)
  Using cached certifi-2017.11.5-py2.py3-none-any.whl
Collecting chardet<3.1.0,>=3.0.2 (from requests>=2.11.1->crossrefapi)
  Using cached chardet-3.0.4-py2.py3-none-any.whl
Installing collected packages: idna, urllib3, certifi, chardet, requests, crossrefapi
Successfully installed certifi-2017.11.5 chardet-3.0.4 crossrefapi-1.2.0 idna-2.6 requests-2.18.4 urllib3-1.22
(testcrossrefapi) Fabios-MacBook-Pro:~ fabiobatalha$ python
Python 2.7.10 (default, Feb  7 2017, 00:08:15)
[GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.34)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from crossref.restful import Works
>>> Works().url
'https://api.crossref.org/works'
>>> ^D
(testcrossrefapi) Fabios-MacBook-Pro:~ fabiobatalha$ pip list
DEPRECATION: The default format will switch to columns in the future. You can use --format=(legacy|columns) (or define a format=(legacy|columns) in your pip.conf under the [list] section) to disable this warning.
certifi (2017.11.5)
chardet (3.0.4)
crossrefapi (1.2.0)
idna (2.6)
pip (9.0.1)
requests (2.18.4)
setuptools (36.7.0)
urllib3 (1.22)
wheel (0.30.0)
mayurpatil1211 commented 6 years ago

@fabiobatalha

mayur@mayur-HP-Notebook:~/Documents/work/zen$ virtualenv crossref
New python executable in /home/mayur/Documents/work/zen/crossref/bin/python
Installing setuptools, pip, wheel...done.
mayur@mayur-HP-Notebook:~/Documents/work/zen$ source crossref/bin/activate
(crossref) mayur@mayur-HP-Notebook:~/Documents/work/zen$ pip install crossrefapiCollecting crossrefapi
Collecting requests>=2.11.1 (from crossrefapi)
  Using cached requests-2.18.4-py2.py3-none-any.whl
Collecting urllib3<1.23,>=1.21.1 (from requests>=2.11.1->crossrefapi)
  Using cached urllib3-1.22-py2.py3-none-any.whl
Collecting idna<2.7,>=2.5 (from requests>=2.11.1->crossrefapi)
  Using cached idna-2.6-py2.py3-none-any.whl
Collecting chardet<3.1.0,>=3.0.2 (from requests>=2.11.1->crossrefapi)
  Using cached chardet-3.0.4-py2.py3-none-any.whl
Collecting certifi>=2017.4.17 (from requests>=2.11.1->crossrefapi)
  Using cached certifi-2017.11.5-py2.py3-none-any.whl
Installing collected packages: urllib3, idna, chardet, certifi, requests, crossrefapi
Successfully installed certifi-2017.11.5 chardet-3.0.4 crossrefapi-1.2.0 idna-2.6 requests-2.18.4 urllib3-1.22
(crossref) mayur@mayur-HP-Notebook:~/Documents/work/zen$ pip list
DEPRECATION: The default format will switch to columns in the future. You can use --format=(legacy|columns) (or define a format=(legacy|columns) in your pip.conf under the [list] section) to disable this warning.

certifi (2017.11.5)
chardet (3.0.4)
crossrefapi (1.2.0)
idna (2.6)
pip (9.0.1)
requests (2.18.4)
setuptools (36.7.0)
urllib3 (1.22)
wheel (0.30.0)
(crossref) mayur@mayur-HP-Notebook:~/Documents/work/zen$ python
Python 2.7.12 (default, Nov 19 2016, 06:48:10) 
[GCC 5.4.0 20160609] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from crossref.restful import Works
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "crossref.py", line 1, in <module>
    from crossref.restful import Works
ImportError: No module named restful
>>> 
fabiobatalha commented 6 years ago

@mayurpatil1211

Try to run:

from crossref import restful works = restful.Works()

mayurpatil1211 commented 6 years ago

@fabiobatalha No sir, i tried that too.

>>> from crossref import restful
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "crossref.py", line 1, in <module>
    from crossref.restful import Works
ImportError: No module named restful