Git Product home page Git Product logo

Comments (13)

Zaletio avatar Zaletio commented on June 9, 2024 1

After almost three days, I got it to work by using the following:

remove.packages('pattern.nlp')
library(findpython)
can_find_python_cmd(required_modules = "pattern.db")
devtools::install_github("bnosac/pattern.nlp", INSTALL_opts = "--no-multiarch")
library(pattern.nlp)

Appartenly, the difference between INSTALL_Opts and args was crucial. Hope this saves time for others and thanks @jwijffels for the quick responses yesterday!

One final question: can pattern_sentiment only be applied to characters put into the console (i.e. test <- pattern_sentiment("hello", language = "english" )?

Or is it also possible to apply it to a dataframe or table column, as I receive the error stating Error in data.table::setDF(score) : All elements in argument 'x' to 'setDF' must be of same length?

from pattern.nlp.

jwijffels avatar jwijffels commented on June 9, 2024

Start R in 32 bit as you seem to have python 32 bit.
If you can't get it to work an this is for a commercial project, you can contact us at www.bnosac.be

from pattern.nlp.

Zaletio avatar Zaletio commented on June 9, 2024

Thanks for the reply! I want to execute a Dutch sentiment analysis as part of my master's thesis, hence it is not a commercial project.

Unfortunately, I already ran the R 32 bit version. Hence, my surprise when this error showed.

Do you have another suggestion, where it could've gone wrong?

I uninstalled Python 32 bits and installed the 64 bits variant. Then, I used the cd c:\Python27\scripts and pip install pattern again. After starting R (64 bits) and running the commands following commands:

 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) 

This led to the following output (the same as above):

> library(findpython)
> can_find_python_cmd(required_modules = "pattern.db")
[1] TRUE
attr(,"python_cmd")
[1] "C:\\Python27\\python.exe"
> devtools::install_github("bnosac/pattern.nlp", args = "--no-multiarch")
Downloading GitHub repo bnosac/pattern.nlp@master
  
   checking for file 'C:\Users\Max\AppData\Local\Temp\RtmpUxH6eT\remotes19543d9e3bf\bnosac-pattern.nlp-91a459f/DESCRIPTION' ...
  
   checking for file 'C:\Users\Max\AppData\Local\Temp\RtmpUxH6eT\remotes19543d9e3bf\bnosac-pattern.nlp-91a459f/DESCRIPTION' ... 
  
√  checking for file 'C:\Users\Max\AppData\Local\Temp\RtmpUxH6eT\remotes19543d9e3bf\bnosac-pattern.nlp-91a459f/DESCRIPTION'

-  preparing 'pattern.nlp':
   checking DESCRIPTION meta-information ...
  
   checking DESCRIPTION meta-information ... 
  
√  checking DESCRIPTION meta-information

  
-  checking for LF line-endings in source and make files and shell scripts
  
-  checking for empty or unneeded directories
  
-  looking to see if a 'data/datalist' file should be added
   
-  building 'pattern.nlp_1.0.tar.gz'

Installing package into ‘C:/Users/Max/Documents/R/win-library/3.5’
(as ‘lib’ is unspecified)
* installing *source* package 'pattern.nlp' ...
** R
** data
** inst
** byte-compile and prepare package for lazy loading
** help
*** installing help indices
  converting help for package 'pattern.nlp'
    finding HTML links ... done
    pattern.nlp-package                     html  
    pattern_pos                             html  
    pattern_sentiment                       html  
    penn_treebank_postags                   html  
** building package indices
** testing if installed package can be loaded
*** arch - i386
Error: package or namespace load failed for 'pattern.nlp':
 .onAttach failed in attachNamespace() for 'pattern.nlp', details:
  call: autodetectPython(pythonExePath)
  error: Python 64bit can't be connected with R 32bit!
Error: loading failed
Execution halted
*** arch - x64
Traceback (most recent call last):

  File "<string>", line 1, in <module>

  File "C:\Python27\lib\site-packages\pattern\text\en\__init__.py", line 61, in <module>

    from pattern.text.en.inflect import (

  File "C:\Python27\lib\site-packages\pattern\text\en\__init__.py", line 80, in <module>
    
from pattern.text.en import wordnet

  File "C:\Python27\lib\site-packages\pattern\text\en\wordnet\__init__.py", line 48, in <module>
    
import nltk

ImportError
: 
No module named nltk
Error: package or namespace load failed for 'pattern.nlp':
 .onAttach failed in attachNamespace() for 'pattern.nlp', details:
  call: PythonInR::pyExec("from pattern.en import sentiment as sentiment_en")
  error: An error has occured while executing Python code. See traceback above.
Error: loading failed
Execution halted
ERROR: loading failed for 'i386', 'x64'
* removing 'C:/Users/Max/Documents/R/win-library/3.5/pattern.nlp'
In R CMD INSTALL
Error in i.p(...) : 
  (converted from warning) installation of package ‘C:/Users/Max/AppData/Local/Temp/RtmpUxH6eT/file1954409c31e3/pattern.nlp_1.0.tar.gz’ had non-zero exit status
> can_find_python_cmd(required_modules = "pattern.db")

Surprisingly, even though I am running R in 64 bit, this time the error indicates that I am running Python in 64 bit and R in 32 bit.

from pattern.nlp.

jwijffels avatar jwijffels commented on June 9, 2024

Maybe install both python 32 as 64 bit as well as pattern for these 2

from pattern.nlp.

jwijffels avatar jwijffels commented on June 9, 2024

The error message about nltk seems like the python pattern package has been updated. As it seems now to need nltk. So either you will have to do also pip install nltk hoping that the update pattern did, did not break this r package or just install pattern version 2.6 which was used to develop this r package

from pattern.nlp.

Zaletio avatar Zaletio commented on June 9, 2024

Installing both Python versions (as well as the pattern module) did not do the trick as the same error occured.

Thus, following your tip, I deinstalled both Python variants and reinstalled Python 2.7.13 64 bit. Next, I downloaded pattern version 2.6 from https://www.clips.uantwerpen.be/pattern.

Then, I ran the commands C:\Users\...\Downloads\pattern-2.6\pattern-2.6 and python setup.py install. This seemed to complete the installation of the pattern package.

So, I started R (64 bit). To be sure, I entered the following commands:

library(xml2)
library(Rcpp)
library(devtools)
library(PythonInR)
library(findpython)
library(digest)
library(data.table)

 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)

This led to the following output:


library(findpython)
> can_find_python_cmd(required_modules = "pattern.db")
[1] TRUE
attr(,"python_cmd")
[1] "C:\\Python27\\python.exe"
> devtools::install_github("bnosac/pattern.nlp", args = "--no-multiarch")
Downloading GitHub repo bnosac/pattern.nlp@master

   checking for file 'C:\Users\Max\AppData\Local\Temp\Rtmpuaktzg\remotes147471d263e8\bnosac-pattern.nlp-91a459f/DESCRIPTION' ...
  
   checking for file 'C:\Users\Max\AppData\Local\Temp\Rtmpuaktzg\remotes147471d263e8\bnosac-pattern.nlp-91a459f/DESCRIPTION' ... 
  
√  checking for file 'C:\Users\Max\AppData\Local\Temp\Rtmpuaktzg\remotes147471d263e8\bnosac-pattern.nlp-91a459f/DESCRIPTION'

-  preparing 'pattern.nlp':
   checking DESCRIPTION meta-information ...
  
   checking DESCRIPTION meta-information ... 
  
√  checking DESCRIPTION meta-information

-  checking for LF line-endings in source and make files and shell scripts

-  checking for empty or unneeded directories

-  looking to see if a 'data/datalist' file should be added

-  building 'pattern.nlp_1.0.tar.gz'

Installing package into ‘C:/Users/Max/Documents/R/win-library/3.5’
(as ‘lib’ is unspecified)
* installing *source* package 'pattern.nlp' ...
** R
** data
** inst
** byte-compile and prepare package for lazy loading
** help
*** installing help indices
  converting help for package 'pattern.nlp'
    finding HTML links ... done
    pattern.nlp-package                     html  
    pattern_pos                             html  
    pattern_sentiment                       html  
    penn_treebank_postags                   html  
** building package indices
** testing if installed package can be loaded
*** arch - i386
Error: package or namespace load failed for 'pattern.nlp':
 .onAttach failed in attachNamespace() for 'pattern.nlp', details:
  call: autodetectPython(pythonExePath)
  error: Python 64bit can't be connected with R 32bit!
Error: loading failed
Execution halted
*** arch - x64
ERROR: loading failed for 'i386'
* removing 'C:/Users/Max/Documents/R/win-library/3.5/pattern.nlp'
In R CMD INSTALL
Error in i.p(...) : 
  (converted from warning) installation of package ‘C:/Users/Max/AppData/Local/Temp/Rtmpuaktzg/file14744d8c3a78/pattern.nlp_1.0.tar.gz’ had non-zero exit status

> library(pattern.nlp)> 
Error in library(pattern.nlp) : there is no package called ‘pattern.nlp’

If it was possible, I would've included a screenshot to support that I am actually using R 64 bit (contrary to the error). Moreover, the fact that can_find_python_cmd(required_modules = "pattern.db") returns [1] TRUE already indicates that I am using the correct bit-version (otherwise the connection with Python could not've been made, right?).

Do you have another suggestion? I'm becoming desperate...

EDIT: I even installed R 3.3.0, hoping that would help. Running the same commands then, let to the following (similar) error:

Downloading GitHub repo bnosac/pattern.nlp@master
  
   checking for file 'C:\Users\Max\AppData\Local\Temp\RtmpygySK0\remotes25cc722e44af\bnosac-pattern.nlp-91a459f/DESCRIPTION' ...
  
   checking for file 'C:\Users\Max\AppData\Local\Temp\RtmpygySK0\remotes25cc722e44af\bnosac-pattern.nlp-91a459f/DESCRIPTION' ... 
  
√  checking for file 'C:\Users\Max\AppData\Local\Temp\RtmpygySK0\remotes25cc722e44af\bnosac-pattern.nlp-91a459f/DESCRIPTION'

-  preparing 'pattern.nlp':
   checking DESCRIPTION meta-information ...
  
   checking DESCRIPTION meta-information ... 
  
√  checking DESCRIPTION meta-information

-  checking for LF line-endings in source and make files

-  checking for empty or unneeded directories

-  looking to see if a 'data/datalist' file should be added

-  building 'pattern.nlp_1.0.tar.gz'

Installing package into ‘C:/Users/Max/Documents/R/win-library/3.3’
(as ‘lib’ is unspecified)
* installing *source* package 'pattern.nlp' ...
** R
** data
** inst
** preparing package for lazy loading
** help
*** installing help indices
** building package indices
** testing if installed package can be loaded
*** arch - i386
Error : .onAttach failed in attachNamespace() for 'pattern.nlp', details:
  call: autodetectPython(pythonExePath)
  error: Python 64bit can't be connected with R 32bit!
Error: loading failed
Execution halted
*** arch - x64
ERROR: loading failed for 'i386'
* removing 'C:/Users/Max/Documents/R/win-library/3.3/pattern.nlp'
Error: (converted from warning) running command '"C:/PROGRA~1/R/R-33~1.0/bin/x64/R" CMD INSTALL -l "C:\Users\Max\Documents\R\win-library\3.3" "C:/Users/Max/AppData/Local/Temp/RtmpygySK0/file25cc403760bb/pattern.nlp_1.0.tar.gz"' had status 1

Therefore, I am running out of possibilities to try. Does anyone have an adequate suggestion?

from pattern.nlp.

jwijffels avatar jwijffels commented on June 9, 2024

Show a screenshot that you are now using 64bit r as it now connects to a 64 bit of python. Use rgui instead of rstudio if you want to be sure.

from pattern.nlp.

Zaletio avatar Zaletio commented on June 9, 2024

r 64 bit errror

As requested, the screenshot from the Rgui.

EDIT: I also uploaded the screenshot from the R 3.3.0 variant I tried:

r 3 3 0 error

from pattern.nlp.

jwijffels avatar jwijffels commented on June 9, 2024

Maybe use the argument args = “--no-test-load --no-multi-arch”

from pattern.nlp.

Zaletio avatar Zaletio commented on June 9, 2024

Same error, unfortunately. Would the version of R matter in this case; i.e. if I would try variant 3.0 could that help?

Moreover; is Rtools necessary to run Pattern.nlp? Looking at the warning 1 error, perhaps it indicates a lack of Rtools? EDIT: NVM, running find_rtools() returns TRUE

from pattern.nlp.

Zaletio avatar Zaletio commented on June 9, 2024

Nvm, I fixed it through the apply function to execute pattern_sentiment to every row of my df. Great package, thanks again to @jwijffels !

from pattern.nlp.

hack-r avatar hack-r commented on June 9, 2024

@Zaletio @jwijffels Yes I can confirm it is INSTALL_Opts not args. I would suggest to publish this in the installation instructions.

from pattern.nlp.

jwijffels avatar jwijffels commented on June 9, 2024

@Zaletio thank you for the note about the usage of INSTALL_opts.
Apparently devtools has changed the argument which allows to pass things to R CMD INSTALL. It was previously called args, now you need to pass that argument directly to the INSTALL_opts argument of install.packages. Hence giving you the installation trouble.
You should really have bugged the author of the devtools package for this as the updates made on the devtools package ecosystem are not backwards-compatible with the previous releases of devtools.

from pattern.nlp.

Related Issues (13)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.