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

issues the installing #1

Closed valentinap closed 7 years ago

valentinap commented 7 years ago

Dear Staff,

I'm encountering some issues when I try to install your package. I run Python 2.7.9. I've correctly installed pattern, but when I go to R to run the second part

devtools::install_github("bnosac/pattern.nlp", args = "--no-multiarch")

I get this error:

devtools::installgithub("bnosac/pattern.nlp", args = "--no-multiarch") Downloading GitHub repo bnosac/pattern.nlp@master from URL https://api.github.com/repos/bnosac/pattern.nlp/zipball/master Installing pattern.nlp '/Library/Frameworks/R.framework/Resources/bin/R' --no-site-file --no-environ --no-save \ --no-restore --quiet CMD INSTALL \ '/private/var/folders/c/km_9j5xn7pjc53pchr527g4c0000gn/T/Rtmp2dLsSE/devtools5fd865431c54/bnosac-pattern.nlp-0802212' \ --library='/Library/Frameworks/R.framework/Versions/3.3/Resources/library' --install-tests \ --no-multiarch

  • 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 Traceback (most recent call last):

File "", line 1, in

ImportError : No module named pattern.db Error : .onAttach failed in attachNamespace() for 'pattern.nlp', details: call: PythonInR::pyExec("from pattern.db import *") error: An error has occured while executing Python code. See traceback above. Errore: loading failed Esecuzione interrotta ERROR: loading failed

Thanks in advance for your help

jwijffels commented 7 years ago

The error message says No module named pattern.db. It means it can not find the pattern package. Please add Python to the PATH before you ran devtools::install_github("bnosac/pattern.nlp", args = "--no-multiarch") and make sure you install the pattern package correctly meaning it ends up in the Python modules folder.

valentinap commented 7 years ago

Thanks for your quick reply.

If I well understand, I need to move the Python folder to the pattern.db folder, correct?

Unfortunately I'm an analyst and not a developer, so this is not really clear for me. Thanks in advance for your help

jwijffels commented 7 years ago

You need to put Python in your PATH. Have you done this? What does Sys.getenv("PATH") give you? Is the location of Python in there?

valentinap commented 7 years ago

This is the PATH result:

/Library/Frameworks/Python.framework/Versions/3.4/bin:/Library/Frameworks/Python.framework/Versions/3.4/bin:/Library/Frameworks/Python.framework/Versions/2.7/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin

but I've got it with the command : $; echo $PATH

jwijffels commented 7 years ago

This means that Python version 3.4 is the first in the search path. The following R code will probably give you the location of Python version 3.4?

library(findpython)
find_python_cmd()

The installation instructions at https://github.com/bnosac/pattern.nlp indicate that this will only work for python 2.5+ Change your PATH accordingly to make sure it finds Python version 2.5+ instead of version 3.4. Ask that to your local admin or set the PYTHON environment variable or do something like this


options(python_cmd = "/Library/Frameworks/Python.framework/Versions/2.7/bin/python")
devtools::install_github("bnosac/pattern.nlp", args = "--no-multiarch")
valentinap commented 7 years ago

Thanks a lot for your support. I've followed your instructions installing findpython and running the command

options(python_cmd = "/Library/Frameworks/Python.framework/Versions/2.7/bin/python")

now the error is:

Skipping install of 'pattern.nlp' from a github remote, the SHA1 (08022122) has not changed since last install. Use force = TRUE to force installation


I've also tried to change the PATH from the terminal with the following command:

sudo -s 'echo "/Library/Frameworks/Python.framework/Versions/2.7/bin:/Library/Frameworks/Python.framework/Versions/3.4/bin:/Library/Frameworks/Python.framework/Versions/3.4/bin:/Library/Frameworks/Python.framework/Versions/2.7/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin" >> /Library/Frameworks/Python.framework/Versions/2.7/bin/Python'

but the output is always (no matter which folder I try to set)

No such file or directory


I've tried to remove and install Python again, I've tried to remove SPSS that has a Python module inside, and I've tried to reinstall Sierra on the computer again. Nothing seems to solve the problem. I have two computers and the problem is the same in both machines.

Do you have any other suggest? Thanks a lot

jwijffels commented 7 years ago

You haven't given the output of

library(findpython)
find_python_cmd()

Neither provided information on your computer - is it Linux/Mac or are you in Windows on another shell?

The first thing you got "Skipping install of 'pattern.nlp' from a github remote, the SHA1 (0802212) has not changed since last install. Use force = TRUE to force installation" is that apparently you already installed pattern.nlp, the output of devtools::install_github indicates that you need to use the following for your case

options(python_cmd = "/Library/Frameworks/Python.framework/Versions/2.7/bin/python") devtools::install_github("bnosac/pattern.nlp", args = "--no-multiarch", force = TRUE)

Please look online on how to set the PATH and how to set an environment variable called PYTHON to your non-standard location where you installed python ("/Library/Frameworks/Python.framework/Versions/2.7/bin/python"). The sudo command just isn't setting the PATH. You can just google on that.

valentinap commented 7 years ago

find_python_cmd() [1] "/Library/Frameworks/Python.framework/Versions/2.7/bin/python"

My computer is a Mac with Sierra on

I've looked dozen of results on google about changing the PATH, and tried a lot of ways. I'll find more and I'll post a question on stackoverflow, maybe I will find a solution

I would love to add your package on my course about text mining and my book, but it's really complicated to install

jwijffels commented 7 years ago

Did you install the pattern Python package as indicated in the README as such, is it in /Library/Frameworks/Python.framework/Versions/2.7/Lib/site-packages ?

valentinap commented 7 years ago

From the begin the steps I followed:

  1. Removed all Python versions
  2. Installed Python 2.7 again
  3. Downloaded pattern 2.6 folder from this link http://www.clips.ua.ac.be/pages/pattern
  4. put the pattern 2.6 folder to this folder

    /Library/Frameworks/Python.framework/Versions/2.7/lib/site-packages

  5. from the terminal, I had run

cd pattern-2.6 python setup.py install

  1. then went to R, required findpython and set the directory with the following code

options(python_cmd = "/Library/Frameworks/Python.framework/Versions/2.7/bin/python")

then installed pattern.nlp with

devtools::install_github("bnosac/pattern.nlp", args = "--no-multiarch", force = TRUE)

The output is:

Traceback (most recent call last):

File "", line 1, in

ImportError : No module named pattern.db Error : .onAttach failed in attachNamespace() for 'pattern.nlp', details: call: PythonInR::pyExec("from pattern.db import *") error: An error has occured while executing Python code. See traceback above. Error: loading failed Execution halted ERROR: loading failed


I've also tried to move the folder to Versions/2.7/bin, but nothing changes.

jwijffels commented 7 years ago

pattern.nlp uses the following code to try to find the Python pattern package which should be installed at your computer. As long as this fails, you can not install pattern.nlp

library(findpython)
can_find_python_cmd(required_modules = "pattern.db")

What you can do is look at the help of ?can_find_python_cmd or look at the source code of edit(find_python_cmd) or edit(can_find_python_cmd) to see what this function does and set the environment variables which are used there to match your specific system and non-standard location where you put Python and the Pattern package.