cytoscape / py2cytoscape

Python utilities for Cytoscape and Cytoscape.js
https://py2cytoscape.readthedocs.io
MIT License
178 stars 45 forks source link

problem importing cyrest from py2cytoscape (python 2.7.15) #99

Closed Benito-chem closed 4 years ago

Benito-chem commented 4 years ago

When importing cyrest, I've got :

from py2cytoscape import cyrest
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python2.7/site-packages/py2cytoscape/cyrest/__init__.py", line 7, in <module>
    from .cyrest import *
  File "/usr/local/lib/python2.7/site-packages/py2cytoscape/cyrest/cyrest.py", line 1, in <module>
    from .base import *
  File "/usr/local/lib/python2.7/site-packages/py2cytoscape/cyrest/base.py", line 7, in <module>
    from json import JSONDecodeError
ImportError: cannot import name JSONDecodeError

Cytoscape version: 3.8.0

CyRest: 0.7.1 pip show py2cytoscape Name: py2cytoscape Version: 0.7.1 Summary: Utilities to use Cytoscape and Cytoscape.js from Python Home-page: https://github.com/idekerlab/py2cytoscape Author: Keiichiro Ono Author-email: kono@ucsd.edu License: MIT License Location: /usr/local/lib/python2.7/site-packages Requires: networkx, python-igraph, requests, pydotplus, pydot, pyparsing, pandas

Do not know what I do wrong or if it is compatible ?

matthiaskoenig commented 4 years ago

My tip would be the python 2 you are still using. Python 2 end of life has been reached and it is highly recommended not to use python 2 for anything any more. Most open source projects already dropped support. You should switch to python 3 and try there. You can use virtual environments or conda environments to manage different versions of python. I just checked this with python 3.8 and python 3.7 and see no issue:

mkoenig@trip3:~$ mkvirtualenv pycyto
created virtual environment CPython3.8.2.final.0-64 in 124ms
  creator CPython3Posix(dest=/home/mkoenig/envs/pycyto, clear=False, global=False)
  seeder FromAppData(download=False, pip=latest, setuptools=latest, wheel=latest, via=copy, app_data_dir=/home/mkoenig/.local/share/virtualenv/seed-app-data/v1.0.1)
  activators BashActivator,CShellActivator,FishActivator,PowerShellActivator,PythonActivator,XonshActivator
virtualenvwrapper.user_scripts creating /home/mkoenig/envs/pycyto/bin/predeactivate
virtualenvwrapper.user_scripts creating /home/mkoenig/envs/pycyto/bin/postdeactivate
virtualenvwrapper.user_scripts creating /home/mkoenig/envs/pycyto/bin/preactivate
virtualenvwrapper.user_scripts creating /home/mkoenig/envs/pycyto/bin/postactivate
virtualenvwrapper.user_scripts creating /home/mkoenig/envs/pycyto/bin/get_env_details
(pycyto) mkoenig@trip3:~$ pip install py2cytoscape
Collecting py2cytoscape
  Downloading py2cytoscape-0.7.1.tar.gz (57 kB)
     |████████████████████████████████| 57 kB 753 kB/s 
Collecting pandas
  Downloading pandas-1.0.5-cp38-cp38-manylinux1_x86_64.whl (10.0 MB)
     |████████████████████████████████| 10.0 MB 1.5 MB/s 
Collecting networkx
  Downloading networkx-2.4-py3-none-any.whl (1.6 MB)
     |████████████████████████████████| 1.6 MB 1.7 MB/s 
Collecting pydot
  Downloading pydot-1.4.1-py2.py3-none-any.whl (19 kB)
Collecting pydotplus
  Downloading pydotplus-2.0.2.tar.gz (278 kB)
     |████████████████████████████████| 278 kB 1.5 MB/s 
Collecting requests
  Using cached requests-2.24.0-py2.py3-none-any.whl (61 kB)
Collecting pyparsing
  Using cached pyparsing-2.4.7-py2.py3-none-any.whl (67 kB)
Collecting python-igraph
  Downloading python_igraph-0.8.2-cp38-cp38-manylinux2010_x86_64.whl (3.2 MB)
     |████████████████████████████████| 3.2 MB 1.7 MB/s 
Collecting pytz>=2017.2
  Using cached pytz-2020.1-py2.py3-none-any.whl (510 kB)
Collecting python-dateutil>=2.6.1
  Using cached python_dateutil-2.8.1-py2.py3-none-any.whl (227 kB)
Collecting numpy>=1.13.3
  Downloading numpy-1.19.0-cp38-cp38-manylinux2010_x86_64.whl (14.6 MB)
     |████████████████████████████████| 14.6 MB 1.8 MB/s 
Collecting decorator>=4.3.0
  Using cached decorator-4.4.2-py2.py3-none-any.whl (9.2 kB)
Collecting urllib3!=1.25.0,!=1.25.1,<1.26,>=1.21.1
  Using cached urllib3-1.25.9-py2.py3-none-any.whl (126 kB)
Collecting idna<3,>=2.5
  Using cached idna-2.10-py2.py3-none-any.whl (58 kB)
Collecting chardet<4,>=3.0.2
  Using cached chardet-3.0.4-py2.py3-none-any.whl (133 kB)
Collecting certifi>=2017.4.17
  Using cached certifi-2020.6.20-py2.py3-none-any.whl (156 kB)
Collecting texttable>=1.6.2
  Downloading texttable-1.6.2-py2.py3-none-any.whl (10 kB)
Collecting six>=1.5
  Using cached six-1.15.0-py2.py3-none-any.whl (10 kB)
Building wheels for collected packages: py2cytoscape, pydotplus
  Building wheel for py2cytoscape (setup.py) ... done
  Created wheel for py2cytoscape: filename=py2cytoscape-0.7.1-py3-none-any.whl size=78812 sha256=739553571302e87f660c11cea4bbcdef8234e71c3342593976c0245658d9b657
  Stored in directory: /home/mkoenig/.cache/pip/wheels/5c/c3/5b/76436ed5d5c54edcb37239175c9e978c7994ffc9f9b5f8472a
  Building wheel for pydotplus (setup.py) ... done
  Created wheel for pydotplus: filename=pydotplus-2.0.2-py3-none-any.whl size=24566 sha256=958de239df3a64ce9e49d84a45582f94b688d99e5dc213aade97f61ddd66151a
  Stored in directory: /home/mkoenig/.cache/pip/wheels/fe/cd/78/a7e873cc049759194f8271f780640cf96b35e5a48bef0e2f36
Successfully built py2cytoscape pydotplus
Installing collected packages: pytz, six, python-dateutil, numpy, pandas, decorator, networkx, pyparsing, pydot, pydotplus, urllib3, idna, chardet, certifi, requests, texttable, python-igraph, py2cytoscape
Successfully installed certifi-2020.6.20 chardet-3.0.4 decorator-4.4.2 idna-2.10 networkx-2.4 numpy-1.19.0 pandas-1.0.5 py2cytoscape-0.7.1 pydot-1.4.1 pydotplus-2.0.2 pyparsing-2.4.7 python-dateutil-2.8.1 python-igraph-0.8.2 pytz-2020.1 requests-2.24.0 six-1.15.0 texttable-1.6.2 urllib3-1.25.9
(pycyto) mkoenig@trip3:~$ python
Python 3.8.2 (default, Apr 27 2020, 15:53:34) 
[GCC 9.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from py2cytoscape import cyrest
Benito-chem commented 4 years ago

Thanks for your email. I figured out last night that works with python3.7.

Someone has to change py2cytoscape homepage and says that it is working only with python 3. anymore

Thanks again Matthias

matthiaskoenig commented 4 years ago

@Benito-chem No problem. Most of the people solve their own issues after some trying.

A good practise is too just post your own solution to your issue and close your issue. Then others searching for the same issue will find your solution. Best Matthias