Closed valentinap closed 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.
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
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?
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
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")
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
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.
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
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 ?
From the begin the steps I followed:
put the pattern 2.6 folder to this folder
/Library/Frameworks/Python.framework/Versions/2.7/lib/site-packages
cd pattern-2.6 python setup.py install
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 "
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.
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.
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:
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