bnosac / pattern.nlp

R package to perform sentiment analysis and Parts of Speech tagging for Dutch/French/English/German/Spanish/Italian
Other
67 stars 17 forks source link

Both R and Python are 64-bit but the installation fails with 32 vs 64 bit error #9

Closed hack-r closed 5 years ago

hack-r commented 5 years ago

My Python 3.7.2 and R 3.5.2 are both 64-bit and are on Windows.

Pattern is installed in Python. I'd like to troubleshoot this directly, but if there's a workaround where I could specific an alternative 32-bit Python installation then that would be an option (?).

The R installation fails anyway with these errors:

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 'pattern.nlp' In R CMD INSTALL Error in i.p(...) : (converted from warning) installation of package ‘RtmpobB6uh/file2188337f981/pattern.nlp_1.0.tar.gz’ had non-zero exit status
hack-r commented 5 years ago

I found the OP's comment here mentioning INSTALL_Opts, and that tweaks allows for a (seemingly) successful installation, however any command just fails with:

Error: '...../postagged-pid8584.xml' does not exist.
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!

5: In pyConnectionCheck() : R isn't connected to Python!

6: In pyConnectionCheck() :

I set PYTHON, PYTHON2, python_cmd, and Python in the PATH because that's everything I've seen mentioned thusfar.

In the dependency PythinInR it mentioned PYTHON_EXE. That didn't help but PythonInR::pyConnect(pythonExePath=PATH) seems to recognize that this is 64-bit R so the 32-bit Python doesn't work with it but the 64-bit does...

After invoking that dependency's command I seem to get a little bit further, but the initial test code still fails with this error:

 Error in pyExec(sprintf("s = Text(%s(%s, tokenize = True, tags = True, chunks = True, lemmata = True, encoding = 'utf-8', relations = True)).xml",  : 

   Traceback (most recent call last):
     File "<string>", line 1, in <module>
   NameError: name 'Text' is not defined 

Alternately:

> x <- pattern_sentiment("i really really hate iphones", language = "english")
Error in pyExec(sprintf("senti = %s(%s)", FUN, pyobj)) : 
   Traceback (most recent call last):
     File "<string>", line 1, in <module>
   NameError: name 'sentiment_en' is not defined

I notice that while that fails, this works:

PythonInR::pyExec("from pattern.db import *")
PythonInR::pyExec("from pattern.en import sentiment as sentiment_en")

Update: After wrestling with this highly promising packaging all weekend, I can get it to work but only by explicitly calling commands from the source code as above, combined with the other installation work arounds. We can close this whenever you are ready, but I imagine my "heavy lifting" workaround isn't the solution you probably want for the larger user community. I'm here if you want to troubleshoot. Thanks!

jwijffels commented 5 years ago

The package uses PythonInR to connect R to Python. Just look at the options you have when connecting to Python as indicated in the PythonInR package (see https://bitbucket.org/Floooo/pythoninr/ or https://CRAN.R-project.org/package=PythonInR)

hack-r commented 5 years ago

I would suggest to re-open this issue as it's unsolved

jwijffels commented 5 years ago

How is this issue not resolved if you follow the README and the README in the Pythonin R package?

Zaletio commented 5 years ago

My suggestions would be:

(1) Check if you have xml2 in use. (2) Check if you're using the pattern2.6 variant. (3) Control the path settings: -> Windows 10 and Windows 8 -> In Search, search for and then select: System (Control Panel) -> Click the Advanced system settings link. -> Click Environment Variables. In the section System Variables, find the PATH environment variable and select it. -> Click Edit. -> If the PATH environment variable does not exist, click New. -> In the Edit System Variable (or New System Variable) window, specify the value of the PATH environment variable. -> I entered into the path (after normal installation of Python) both C:\Python27\; and "C:\Python27\python.exe. -> Click OK. Close all remaining windows by clicking OK. -> Reboot R and try to use PyConnect from the PythonInR package (see here for details).

If this does not work; I suggest to reinstall Python and reinstall the Pattern2.6 package, since it does seem from this error (NameError: name 'sentiment_en' is not defined) that something went wrong there.