Closed iamrajeshchauhan closed 7 years ago
Have you installed Python and the Python pattern package as indicated in the readme?
Make sure it is in the PATH or set the PYTHON, PYTHON2 environment variables to the location where you installed Python and the pattern package.
You can look at Sys.getenv()
to see the environment variables known to R to see if R picks up these envirnoment variables.
Yes I checked with sys.getenv() , but it is not picking up the PYTHON , PYTHON2 ,
So How do I get this resolve ? In R
Can you print out Sys.getenv()
and inform on the type of OS you are working on?
I am working on windows
the output is
Sys.getenv() ALLUSERSPROFILE C:\ProgramData APPDATA C:\Users\eDAS\AppData\Roaming CommonProgramFiles C:\Program Files\Common Files CommonProgramFiles(x86) C:\Program Files (x86)\Common Files CommonProgramW6432 C:\Program Files\Common Files COMPUTERNAME EDAS-PC ComSpec C:\WINDOWS\system32\cmd.exe DISPLAY :0 FP_NO_HOST_CHECK NO FPS_BROWSER_APP_PROFILE_STRING Internet Explorer FPS_BROWSER_USER_PROFILE_STRING Default GFORTRAN_STDERR_UNIT -1 GFORTRAN_STDOUT_UNIT -1 HOME C:/Users/eDAS/Documents HOMEDRIVE C: HOMEPATH \Users\eDAS LOCALAPPDATA C:\Users\eDAS\AppData\Local LOGONSERVER \EDAS-PC MSMPI_BIN C:\Program Files\Microsoft MPI\Bin\ NUMBER_OF_PROCESSORS 4 OneDrive C:\Users\eDAS\OneDrive OS Windows_NT PATH C:\Program Files\R\R-3.3.2\bin\x64;C:\Program Files\Microsoft MPI\Bin\;C:\ProgramData\Oracle\Java\javapath;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\Program Files\Cloud Foundry;C:\Users\eDAS\AppData\Local\Microsoft\WindowsApps; PATHEXT .COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC PROCESSOR_ARCHITECTURE AMD64 PROCESSOR_IDENTIFIER Intel64 Family 6 Model 58 Stepping 9, GenuineIntel PROCESSOR_LEVEL 6 PROCESSOR_REVISION 3a09 ProgramData C:\ProgramData ProgramFiles C:\Program Files ProgramFiles(x86) C:\Program Files (x86) ProgramW6432 C:\Program Files PSModulePath C:\WINDOWS\system32\WindowsPowerShell\v1.0\Modules\ PUBLIC C:\Users\Public R_ARCH /x64 R_COMPILED_BY gcc 4.9.3 R_DOC_DIR C:/PROGRA~1/R/R-33~1.2/doc R_HOME C:/PROGRA~1/R/R-33~1.2 R_LIBS_USER C:/Users/eDAS/Documents/R/win-library/3.3 R_USER C:/Users/eDAS/Documents RMARKDOWN_MATHJAX_PATH C:/Program Files/RStudio/resources/mathjax-26 RS_LOCAL_PEER \.\pipe\26373-rsession RS_RPOSTBACK_PATH C:/Program Files/RStudio/bin/rpostback RS_SHARED_SECRET 63341846741 RSTUDIO 1 RSTUDIO_MSYS_SSH C:/Program Files/RStudio/bin/msys-ssh-1000-18 RSTUDIO_PANDOC C:/Program Files/RStudio/bin/pandoc RSTUDIO_SESSION_PORT 26373 RSTUDIO_USER_IDENTITY eDAS RSTUDIO_WINUTILS C:/Program Files/RStudio/bin/winutils SESSIONNAME Console SystemDrive C: SystemRoot C:\WINDOWS TEMP C:\Users\eDAS\AppData\Local\Temp TMP C:\Users\eDAS\AppData\Local\Temp USERDOMAIN EDAS-PC USERDOMAIN_ROAMINGPROFILE EDAS-PC USERNAME eDAS USERPROFILE C:\Users\eDAS windir C:\WINDOWS windows_tracing_flags 3 windows_tracing_logfile C:\BVTBin\Tests\installpackage\csilogfile.log
Look online to how to add something to the path as in https://www.java.com/en/download/help/path.xml You need to add the location where you installed Python to the path. E.g. by adding C:\Python27 to the path if you installed python there.
I have install PYTHON also, the thing is as you said " C:\Python27 " path I have given path also now thing is while running below code: I am getting following error
x <- pattern_sentiment("i really really hate iphones", language = "english")
Error in data.table::setDF(score) : All elements in argument 'x' to 'setDF' must be of same length In addition: Warning messages: 1: In pyConnectionCheck() : R isn't connected to Python!
2: In pyConnectionCheck() : R isn't connected to Python!
3: In pyConnectionCheck() : R isn't connected to Python!
4: In pyConnectionCheck() : R isn't connected to Python!
SO I guess R can not connecting to PYTHON library how to resolve.
Can you restart R and let me know what library(pattern.nlp)
gives you?
Yes I have restarted R but error is still same. what should be way to connect R with python ? and while running library(pattern.nlp) it is executing properly no error.
I'm trying to find out if you installed Python/pattern correctly and set the PATH correctly. Can you give the output of
list.files("C:/Python27/Lib/site-packages")
Sys.getenv("PATH")
Sys.getenv("PYTHON")
Sys.getenv("PYTHON2")
R.version
installed.packages()["pattern.nlp", ]
library(findpython)
can_find_python_cmd(required_modules = "pattern.db")
"easy_install.py" "easy_install.pyc" "pattern-2.6"
[4] "pip" "pip-9.0.1.dist-info" "pkg_resources"
[7] "README.txt" "setuptools" "setuptools-28.8.0.dist-info"
x <- pattern_sentiment("i really really hate iphones", language = "english")
and getting same error of not connecting to R
Can you just provide the output of the code I sent you, run the code in a clean R session and copy-paste the R console output in here
list.files("C:/Python27/Lib/site-packages")
[1] "easy_install.py" "easy_install.pyc" "pattern-2.6"
[4] "pip" "pip-9.0.1.dist-info" "pkg_resources"
[7] "README.txt" "setuptools" "setuptools-28.8.0.dist-info"
> Sys.getenv("PATH")
[1] "C:\\Program Files\\R\\R-3.3.2\\bin\\x64;C:\\path\\to\\binary;C:\\Python27\\Lib;C:\\Program Files\\Microsoft MPI\\Bin\\;C:\\ProgramData\\Oracle\\Java\\javapath;C:\\WINDOWS\\system32;C:\\WINDOWS;C:\\WINDOWS\\System32\\Wbem;C:\\WINDOWS\\System32\\WindowsPowerShell\\v1.0\\;C:\\Program Files\\Cloud Foundry;C:\\Users\\eDAS\\AppData\\Local\\Microsoft\\WindowsApps;"
> Sys.getenv("PYTHON")
[1] ""
> Sys.getenv("PYTHON2")
[1] ""
> R.version
_
platform x86_64-w64-mingw32
arch x86_64
os mingw32
system x86_64, mingw32
status
major 3
minor 3.2
year 2016
month 10
day 31
svn rev 71607
language R
version.string R version 3.3.2 (2016-10-31)
nickname Sincere Pumpkin Patch
> installed.packages()["pattern.nlp", ]
Package
"pattern.nlp"
LibPath
"C:/Users/eDAS/Documents/R/win-library/3.3"
Version
"1.0"
Priority
NA
Depends
"\nR (>= 2.15)"
Imports
"\ndata.table,\nfindpython,\nPythonInR,\ndigest,\nxml2"
LinkingTo
NA
Suggests
"\nknitr"
Enhances
NA
License
"AGPL-3 + file LICENSE"
License_is_FOSS
NA
License_restricts_use
NA
OS_type
NA
MD5sum
NA
NeedsCompilation
NA
Built
"3.3.2"
>
I see you put C:\Python27\Lib in the PATH, you should put C:\Python27 in the PATH instead. Can you do that.
I did but still same issue
Sys.getenv("PATH") [1] "C:\Program Files\R\R-3.3.2\bin\x64;C:\Python27;C:\Program Files\Microsoft MPI\Bin\;C:\ProgramData\Oracle\Java\javapath;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\Program Files\Cloud Foundry;C:\Users\eDAS\AppData\Local\Microsoft\WindowsApps;"
Can you reinstall the package as only now your PATH to Python is set correctly. Can you do the following and give the full output of the below code from the R console
remove.packages('pattern.nlp')
library(findpython)
can_find_python_cmd(required_modules = "pattern.db")
devtools::install_github("bnosac/pattern.nlp", args = "--no-multiarch")
library(pattern.nlp)
I feel issue is something different. after doing above code. I also getting same error so I tried to run below code. So while doing this I got the error. This is even after running library and installing package.
can_find_python_cmd(required_modules = "pattern.db")
Error in find_python_cmd(minimum_version = minimum_version, maximum_version = maximum_version, : Couldn't find a sufficient Python binary. If you haven't installed the Python dependency yet please do so. If you have but it isn't on the system path (as is default on Windows) please add it to path or set options('python_cmd'='/path/to/binary') or set the PYTHON, PYTHON2, or PYTHON3 environmental variables. Python must have access to the modules: pattern.db [1] FALSE
The error message says it can not find the pattern python package which you should have installed with pip install pattern
as specified in the README. Did you do that? As in
cd C:\Python27\Scripts
pip install pattern
Also make sure your when you run the R version (64/32 bit) it is the same as the Python version you installed (64/32 bit). The output of R.version indicates that you are using 64bit R. Might also be the case that you need to use 32bit R to be compatible with the Python version you installed. In that case and assuming that you are using RStudio, Go to Tools > Global Options and change the appropriate R version to 32 bit instead and restart RStudio and provide the output of
remove.packages('pattern.nlp')
library(findpython)
can_find_python_cmd(required_modules = "pattern.db")
devtools::install_github("bnosac/pattern.nlp", args = "--no-multiarch")
library(pattern.nlp)
Thanks a lot, I found the problem which is stuck run the library.
Thank you so much for wonderful support.
Btw it is great package to use in R.
great
This helps a lot.
Also for anyone struggling to compiled pattern or its dependencies on Windows in Python to setup the R package - you might find using a precompiled binary easier. They are available here:
https://www.lfd.uci.edu/~gohlke/pythonlibs/
Year in and our, so much hinges on the author of that page. The community should really help him out more.
as per the steps, I have Install all the packages and python. But while running library(pattern.nlp) I am getting below error.
Error in find_python_cmd(minimum_version = minimum_version, maximum_version = maximum_version, : Couldn't find a sufficient Python binary. If you haven't installed the Python dependency yet please do so. If you have but it isn't on the system path (as is default on Windows) please add it to path or set options('python_cmd'='/path/to/binary') or set the PYTHON, PYTHON2, or PYTHON3 environmental variables. Python must have access to the modules: pattern.db
Also, I had tried to code in R instead of R studio still the error is not working out.
Second Issue is sometimes it gives the error of, " could connect to python in R "
so please could you help out for this.