Closed moldach closed 11 months ago
Can you show the full python traceback? You may have to do this in repl_python or in python itself.
Also, can you print the contents of your working directory? I suspect there may be a folder in your working directory called phate
which may be being imported instead of the installed package.
Hi @scottgigante
Things had become so hopeless that I had to result to 💣R/Python/Anaconda
and start from a clean-slate. This should make things easier to trouble shoot now though as I've followed THE RStudio directions for setting up Python/reticulate with R after having installed Python with anaconda.
In the terminal:
which python
/home/tsundoku/anaconda3/bin/python
which pip
/home/tsundoku/anaconda3/bin/pip
Create a virtualenv
:
/home/tsundoku/anaconda3/bin/virtualenv .venv
Using base prefix '/home/tsundoku/anaconda3'
New python executable in /home/tsundoku/RProjects/phate-test/.venv/bin/python
Installing setuptools, pip, wheel...
done.
Now source the environment and print which python
again:
source .venv/bin/activate
(.venv) tsundoku@tsundoku-OptiPlex-7070:~/RProjects/phate-test$ which python
/home/tsundoku/RProjects/phate-test/.venv/bin/python
Try to install PHATE as recommended with --user
param (it doesn't like it):
pip install --user phate
ERROR: Can not perform a '--user' install. User site-packages are not visible in this virtualenv.
Remove --user
param:
pip install phate
Collecting phate
Using cached phate-1.0.2-py3-none-any.whl (22 kB)
Collecting Deprecated
Using cached Deprecated-1.2.7-py2.py3-none-any.whl (8.3 kB)
Collecting scprep>=0.11.1
Using cached scprep-1.0.3-py3-none-any.whl (95 kB)
Collecting matplotlib>=3.0
Using cached matplotlib-3.1.2-cp37-cp37m-manylinux1_x86_64.whl (13.1 MB)
Collecting scipy>=1.1.0
Using cached scipy-1.4.1-cp37-cp37m-manylinux1_x86_64.whl (26.1 MB)
Collecting scikit-learn>=0.20.0
Using cached scikit_learn-0.22.1-cp37-cp37m-manylinux1_x86_64.whl (7.0 MB)
Collecting numpy>=1.16.0
Using cached numpy-1.18.1-cp37-cp37m-manylinux1_x86_64.whl (20.1 MB)
Collecting graphtools>=1.3.1
Using cached graphtools-1.4.1-py3-none-any.whl (39 kB)
Processing /home/tsundoku/.cache/pip/wheels/56/b0/fe/4410d17b32f1f0c3cf54cdfb2bc04d7b4b8f4ae377e2229ba0/future-0.18.2-py3-none-any.whl
Collecting tasklogger>=1.0
Using cached tasklogger-1.0.0-py3-none-any.whl (14 kB)
Collecting sgdpy>=1.4.1
Using cached sgdpy-1.4.1-cp37-cp37m-manylinux2010_x86_64.whl (480 kB)
Processing /home/tsundoku/.cache/pip/wheels/23/5f/62/304b411f20be41821465a82bc98baabc5e68c3cdd1eb99db71/wrapt-1.11.2-cp37-cp37m-linux_x86_64.whl
Collecting decorator>=4.3.0
Using cached decorator-4.4.1-py2.py3-none-any.whl (9.2 kB)
Collecting pandas>=0.25
Using cached pandas-0.25.3-cp37-cp37m-manylinux1_x86_64.whl (10.4 MB)
Collecting python-dateutil>=2.1
Using cached python_dateutil-2.8.1-py2.py3-none-any.whl (227 kB)
Collecting pyparsing!=2.0.4,!=2.1.2,!=2.1.6,>=2.0.1
Using cached pyparsing-2.4.6-py2.py3-none-any.whl (67 kB)
Collecting cycler>=0.10
Using cached cycler-0.10.0-py2.py3-none-any.whl (6.5 kB)
Collecting kiwisolver>=1.0.1
Using cached kiwisolver-1.1.0-cp37-cp37m-manylinux1_x86_64.whl (90 kB)
Collecting joblib>=0.11
Using cached joblib-0.14.1-py2.py3-none-any.whl (294 kB)
Collecting pygsp>=0.5.1
Using cached PyGSP-0.5.1-py2.py3-none-any.whl (1.8 MB)
Collecting pytz>=2017.2
Using cached pytz-2019.3-py2.py3-none-any.whl (509 kB)
Collecting six>=1.5
Using cached six-1.14.0-py2.py3-none-any.whl (10 kB)
Requirement already satisfied: setuptools in ./.venv/lib/python3.7/site-packages (from kiwisolver>=1.0.1->matplotlib>=3.0->phate) (45.1.0)
Installing collected packages: wrapt, Deprecated, numpy, scipy, decorator, joblib, scikit-learn, six, python-dateutil, pytz, pandas, scprep, pyparsing, cycler, kiwisolver, matplotlib,pygsp, future, tasklogger, graphtools, sgdpy, phate
Successfully installed Deprecated-1.2.7 cycler-0.10.0 decorator-4.4.1 future-0.18.2 graphtools-1.4.1 joblib-0.14.1 kiwisolver-1.1.0 matplotlib-3.1.2 numpy-1.18.1 pandas-0.25.3 phate-1.0.2 pygsp-0.5.1 pyparsing-2.4.6 python-dateutil-2.8.1 pytz-2019.3 scikit-learn-0.22.1 scipy-1.4.1 scprep-1.0.3 sgdpy-1.4.1 six-1.14.0
Now within .Rprofile
set:
Sys.setenv(RETICULATE_PYTHON = ".venv/bin/python")
Restart RStudio and try to install phateR
:
install.packages("phateR")
Installing package into ‘/usr/local/lib/R/site-library’
(as ‘lib’ is unspecified)
trying URL 'https://cloud.r-project.org/src/contrib/phateR_1.0.0.tar.gz'
Content type 'application/x-gzip' length 3971691 bytes (3.8 MB)
==================================================
downloaded 3.8 MB
* installing *source* package ‘phateR’ ...
** package ‘phateR’ successfully unpacked and MD5 sums checked
** using staged installation
** R
** data
*** moving datasets to lazyload DB
** inst
** byte-compile and prepare package for lazy loading
** help
*** installing help indices
*** copying figures
** building package indices
** testing if installed package can be loaded from temporary location
Error: package or namespace load failed for ‘phateR’:
.onLoad failed in loadNamespace() for 'phateR', details:
call: reticulate::py_discover_config(required_module = "phate")
error: Python specified in RETICULATE_PYTHON (.venv/bin/python) does not exist
Error: loading failed
** testing if installed package can be loaded from final location
Error: package or namespace load failed for ‘phateR’:
.onLoad failed in loadNamespace() for 'phateR', details:
call: reticulate::py_discover_config(required_module = "phate")
error: Python specified in RETICULATE_PYTHON (.venv/bin/python) does not exist
Error: loading failed
Error: .onLoad failed in loadNamespace() for 'phateR', details:
call: reticulate::py_discover_config(required_module = "phate")
error: Python specified in RETICULATE_PYTHON (.venv/bin/python) does not exist
** testing if installed package keeps a record of temporary installation path
* DONE (phateR)
The downloaded source packages are in
‘/tmp/RtmpRS9la9/downloaded_packages’
Here is my sessionInfo()
:
R version 3.6.2 (2019-12-12)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 18.04.3 LTS
Matrix products: default
BLAS: /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.7.1
LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.7.1
locale:
[1] LC_CTYPE=en_CA.UTF-8 LC_NUMERIC=C LC_TIME=en_CA.UTF-8 LC_COLLATE=en_CA.UTF-8
[5] LC_MONETARY=en_CA.UTF-8 LC_MESSAGES=en_CA.UTF-8 LC_PAPER=en_CA.UTF-8 LC_NAME=C
[9] LC_ADDRESS=C LC_TELEPHONE=C LC_MEASUREMENT=en_CA.UTF-8 LC_IDENTIFICATION=C
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] reticulate_1.14 BRRR_1.2
loaded via a namespace (and not attached):
[1] compiler_3.6.2 magrittr_1.5 tools_3.6.2 rappdirs_0.3.1 Rcpp_1.0.3 audio_0.1-6 stringi_1.4.5 jsonlite_1.6
[9] stringr_1.4.0
From the terminal again if I try and import phate
it doesn't work (I guess that makes sense since I'm doing the install in a virtualenv
- it shouldn't be available globally)
python
Python 3.7.4 (default, Aug 13 2019, 20:35:49)
[GCC 7.3.0] :: Anaconda, Inc. on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import phate
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'phate'
Hopefully these details can help solve the issue. Please note that the RStudio method of using a virtualenv
worked for numerous other python packages for me: umap-learn, fast_tsne, fastcluster, scipy, sklearn, etc.
Hi @moldach,
This is a bit beyond my expertise...one thing I might try. In the line where you declare the ‘RETICULATE_PYTHON’ variable, try using the full path to the venv. Let me know if that doesn’t work and I’ll consult with some more knowledgeable folks.
Some further troubleshooting:
source .venv/bin/activate; python -c 'import phate; print(phate.__version__)'
, does that work?R -e 'Sys.setenv(RETICULATE_PYTHON = ".venv/bin/python"); reticulate::py_discover_config("phate")'
?Hi @moldach,
This is a bit beyond my expertise...one thing I might try. In the line where you declare the ‘RETICULATE_PYTHON’ variable, try using the full path to the venv. Let me know if that doesn’t work and I’ll consult with some more knowledgeable folks.
So originally I had set RETICULATE_PYTHON
as suggested in the RStudio tutorial: Sys.setenv(RETICULATE_PYTHON = ".venv/bin/python")
Changing this to the full path of the venv
works!: Sys.setenv(RETICULATE_PYTHON = "/home/tsundoku/RProjects/phate-test/.venv/bin/python")
.
This is problematic though when working on different projects/venv's....
I suppose @scottgigante suggestion works also but wondering if this can be improved for users so they won't have to (remember) to place Sys.setenv(RETICULATE_PYTHON = ".venv/bin/python")
after calling library(reticulate)
in every project/script 🤔
R -e 'Sys.setenv(RETICULATE_PYTHON = ".venv/bin/python"); reticulate::py_discover_config("phate")'
python: /home/tsundoku/RProjects/phate-test/.venv/bin/python
libpython: /home/tsundoku/anaconda3/lib/libpython3.7m.so
pythonhome: /home/tsundoku/anaconda3:/home/tsundoku/anaconda3
virtualenv: /home/tsundoku/RProjects/phate-test/.venv/bin/activate_this.py
version: 3.7.4 (default, Aug 13 2019, 20:35:49) [GCC 7.3.0]
numpy: /home/tsundoku/RProjects/phate-test/.venv/lib/python3.7/site-packages/numpy
numpy_version: 1.18.1
phate: /home/tsundoku/RProjects/phate-test/.venv/lib/python3.7/site-packages/phate
NOTE: Python version was forced by RETICULATE_PYTHON
Thank you for your help and prompt response - I appreciate it.
Hi @moldach ,
You can set RETICULATE_PYTHON
in your .Renviron
file, either in the local directory to have this set for any projects run in that directory, or in your home directory to have this set for all R sessions. See more: https://stat.ethz.ch/R-manual/R-devel/library/base/html/Startup.html
That aside, in theory py_discover_config
should find PHATE automatically. Could you try running
R -e 'reticulate::py_discover_config("phate")'
?
Thanks for sharing that, I'll have to take a look later.
(.venv) tsundoku@tsundoku-OptiPlex-7070:~/RProjects/UMAP-examples-mammoth-$ R -e 'reticulate::py_discover_config("phate")'
R version 3.6.2 (2019-12-12) -- "Dark and Stormy Night"
Copyright (C) 2019 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.
Natural language support but running in an English locale
R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.
Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.
> reticulate::py_discover_config("phate")
python: /home/tsundoku/RProjects/phate-test/.venv/bin/python
libpython: /home/tsundoku/anaconda3/lib/libpython3.7m.so
pythonhome: /home/tsundoku/anaconda3:/home/tsundoku/anaconda3
virtualenv: /home/tsundoku/RProjects/phate-test/.venv/bin/activate_this.py
version: 3.7.4 (default, Aug 13 2019, 20:35:49) [GCC 7.3.0]
numpy: /home/tsundoku/RProjects/phate-test/.venv/lib/python3.7/site-packages/numpy
numpy_version: 1.18.1
phate: /home/tsundoku/RProjects/phate-test/.venv/lib/python3.7/site-packages/phate
NOTE: Python version was forced by RETICULATE_PYTHON
After running this I'm able to import phate
Excellent, glad to hear it. Feel free to close this issue if you're successfully up and running.
I had
phateR
working on my computer for about a day and now all of a sudden it's stopped working.Trying to follow trouble shooting from Issue #22:
Then I enter the python terminal:
Then I need to reinstall some stuff:
I restart Rstudio and then try to import phate in python: