NLTK | Sentiment Classifier | Issues with Install - python

I am having trouble installing the sentiment_classifier.
What I have currently done:
pip install sentiment_classifier
python setup.py install
Downloaded sentiment_classifier-0.5.tar.gz
Placed the package into my directory
Error in shell:
pip install sentiment_classifier:
Requirement already satisfied: sentiment_classifier in c:\users\ac\anaconda3\lib\site-packages
Requirement already satisfied: numpy in c:\users\ac\anaconda3\lib\site-packages (from sentiment_classifier)
Requirement already satisfied: nltk in c:\users\ac\anaconda3\lib\site-packages (from sentiment_classifier)
Requirement already satisfied: argparse in c:\users\ac\anaconda3\lib\site-packages (from sentiment_classifie
)
python setup.py install - C:\Users\AC\Anaconda3\python.exe: can't open file 'setup.py': [Errno 2] No such file or directory
When I call it in Jupyter Notebook:
from senti_classifier import senti_classifier
I get:
FileNotFoundError: [Errno 2] No such file or directory: 'C:\Users\AC\Anaconda3\lib\site-packages\senti_classifier\data\SentiWn.p'
Any help would be greatly appreciated.
Docs I've been referring to:
https://pypi.python.org/pypi/sentiment_classifier
Sentiment Analysis using senti_classifier and NLTK
https://github.com/kevincobain2000/sentiment_classifier
http://pythonhosted.org/sentiment_classifier/
Any help would be greatly appreciated.

It is missing some files needed for it to work and no those files aren't downloaded when you install the package using pip, you can download the repository for the library from https://github.com/kevincobain2000/sentiment_classifier and then copy paste the files inside the '/src/senti_classifier/data/' into your library's directory which is 'C:\Users\AC\Anaconda3\lib\site-packages\senti_classifier\data' directory.

Related

Running pytesseract in Sagemaker Jupyter notebook

I want to use pytesseract in my Sagemaker Jupyter notebook.
I am following this tutorial for installing pytesseract. After running pip install:
!pip install pytesseract
Looking in indexes: https://pypi.org/simple, https://pip.repos.neuron.amazonaws.com
Requirement already satisfied: pytesseract in /home/ec2-user/anaconda3/envs/pytorch_p38/lib/python3.8/site-packages (0.3.10)
Requirement already satisfied: Pillow>=8.0.0 in /home/ec2-user/anaconda3/envs/pytorch_p38/lib/python3.8/site-packages (from pytesseract) (9.0.1)
Requirement already satisfied: packaging>=21.3 in /home/ec2-user/anaconda3/envs/pytorch_p38/lib/python3.8/site-packages (from pytesseract) (21.3)
Requirement already satisfied: pyparsing!=3.0.5,>=2.0.2 in /home/ec2-user/anaconda3/envs/pytorch_p38/lib/python3.8/site-packages (from packaging>=21.3->pytesseract) (3.0.6)
the turotial indicates I should add the tesseract executeable to my path however I don't know where pip installs this executable?
# If you don't have tesseract executable in your PATH, include the following:
pytesseract.pytesseract.tesseract_cmd = r'<full_path_to_your_tesseract_executable>'
if I try to run pytesseract without this I get an error message:
from PIL import Image
import pytesseract
print(pytesseract.image_to_string(Image.open(testimage)))
results in:
~/anaconda3/envs/pytorch_p38/lib/python3.8/site-packages/pytesseract/pytesseract.py in run_tesseract(input_filename, output_filename_base, extension, lang, config, nice, timeout)
258 raise
259 else:
--> 260 raise TesseractNotFoundError()
261
262 with timeout_manager(proc, timeout) as error_string:
TesseractNotFoundError: tesseract is not installed or it's not in your PATH. See README file for more information.
I was able to find to the pytesseract instalation here:
/home/ec2-user/anaconda3/envs/JupyterSystemEnv/lib/python3.7/site-packages/pytesseract
however when I update the tesseract_cmd with that location and invoke the same code I get:
PermissionError: [Errno 13] Permission denied: '/home/ec2-user/anaconda3/envs/JupyterSystemEnv/lib/python3.7/site-packages/pytesseract'
My question is distinct (but related) from this question and I am getting a permission denied error when I link to the tesseract binary.

Is my python environment broken? Unable to install gastrodon using PIP

Using Python 3.8 on Windows, having installed a number of other modules I have tried to install gastrodon with
(property) C:\Users\andyt>pip install gastrodon
The result is this:
Requirement already satisfied: gastrodon in c:\users\andyt\anaconda3\envs\property\lib\site-packages (0.9.3)
Requirement already satisfied: pandas in c:\users\andyt\anaconda3\envs\property\lib\site-packages (from gastrodon) (1.0.3)
Requirement already satisfied: IPython in c:\users\andyt\anaconda3\envs\property\lib\site-packages (from gastrodon) (7.13.0)
WARNING: No metadata found in c:\users\andyt\anaconda3\envs\property\lib\site-packages
ERROR: Could not install packages due to an EnvironmentError: [Errno 2] No such file or directory: 'c:\\users\\andyt\\anaconda3\\envs\\property\\lib\\site-packages\\ipython-7.13.0.dist-info\\METADATA'
Does anyone know how to fix this? I am able to install it in base...
Have you tried turning it on and off again? I mean potentially uninstall and reinstall it. I had a similar problem downloading numpy a while back and that seemed to fix it.
so I renamed metadata.json to metadata in a few similar positions where the install failed sequentially, and it appeared to have been successful, except I am now dealing with another error when trying to import gastrodon...

No Module named Slugify in Odoo 12

I came across a module from GitHub and I went through the steps to install, but I am getting this error:
Unable to install module because an external dependency is not met: No module named slugify
However, Slugify is installed:
Requirement already satisfied: python-slugify in c:\program files (x86)\python37-32\lib\site-packages (from -r requirements.txt (line 1)) (3.0.3)
Requirement already satisfied: text-unidecode==1.2 in c:\program files (x86)\python37-32\lib\site-packages (from python-slugify->-r requirements.txt (line 1)) (1.2)
I am using the following parameters for testing:
OS: Windows 10 Pro 64 Bit
Odoo 12.0-20181022 (Community Edition)
Can anyone please advise me where I failed?
Thanks in advance for your help.
Open the same python virtual environment that Odoo uses and run:
try:
import slugify
except ModuleNotFoundError:
import sys
print("Module not found under the following directories: %s"%sys.path)

For python, install hdf5/netcdf4

Doing this on a Linux Mint 17.1.
When I try:
pip install hdf5
I get the error
"Could not find a version that satisfies the requirement hdf5 (from versions: )
No matching distribution found for hdf5"
I'm trying in the long run to install netcdf4 but can't do that until I get hdf5 installed. Supposedly from when I was trying to do this last week, with netcdf4, I should be using the pip install netcdf4, err hdf5...at least maybe in the case of hdf5.
If I try pip install h5py I get that the message saying:
Requirement already satisfied (use --upgrade to upgrade): h5py in ./anaconda3/lib/python3.5/site-packages
Requirement already satisfied (use --upgrade to upgrade): numpy>=1.6.1 in ./anaconda3/lib/python3.5/site-packages (from h5py)
Requirement already satisfied (use --upgrade to upgrade): six in ./anaconda3/lib/python3.5/site-packages (from h5py)
Yet if I go ahead and try pip install netcdf4 it comes up and says:
Collecting netcdf4
Using cached netCDF4-1.2.3.1.tar.gz
Complete output from command python setup.py egg_info:
Package hdf5 was not found in the pkg-config search path.
Perhaps you should add the directory containinghdf5.pc'
to the PKG_CONFIG_PATH environment variable
No package 'hdf5' found
cython version 0.23.4 found ...
reading from setup.cfg...
HDF5_DIR environment variable not set, checking some standard locations ..
checking /home/meant2b ...
checking /usr/local ...
checking /sw ...
checking /opt ...
checking /opt/local ...
checking /usr ...
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/pip-build-pq3yt4ek/netcdf4/setup.py", line 286, in <module>
raise ValueError('did not find HDF5 headers')
ValueError: did not find HDF5 headers
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-pq3yt4ek/netcdf4/`
When I search the files I don't find a hdf5.pc file.
Is there a difference between h5py and hdf5? Do I have to compile and install hdf5 from the individual files or can I pip install.
What do I have to do to be able to install both hdf5 and netcdf4?
You need to install the HDF5 libraries for your Linux distribution. In Ubuntu is:
sudo apt-get install libhdf5-serial-dev netcdf-bin libnetcdf-dev
See this link.
I had the same issue in Debian 8. To fix it, as root, I installed the libraries, then linked the serial headers to a include dir inside the hdf5 libraries, exported the HDF_DIR path and installed netCDF4:
# apt-get install -y libhdf5-dev libnetcdf-dev
# ln -s /usr/include/hdf5/serial /usr/include/hdf5/include
# export HDF5_DIR=/usr/include/hdf5
# pip install netCDF4
I had the same error under macOS Catalina. Had to install the hdf5 and netcdf4 packages from Homebrew:
brew install hdf5 netcdf4
Afterwards, pip3 install netcdf4 worked fine.

Installing Python module with pip

I'm trying to install a module called Scrapy. I installed it using
pip install Scrapy
I see the 'scrapy' folder in my /usr/local/lib/python2.7/site-packages, but when I try to import it in a Python program, is says there is no module by that name. Any ideas as to why this might be happening?
EDIT: Here is the output of the pip command:
Downloading/unpacking Scrapy
Downloading Scrapy-0.20.0.tar.gz (745kB): 745kB downloaded
Running setup.py egg_info for package Scrapy
no previously-included directories found matching 'docs/build'
Requirement already satisfied (use --upgrade to upgrade): Twisted>=10.0.0 in /usr/local/lib/python2.7/site-packages (from Scrapy)
Requirement already satisfied (use --upgrade to upgrade): w3lib>=1.2 in /usr/local/lib/python2.7/site-packages (from Scrapy)
Requirement already satisfied (use --upgrade to upgrade): queuelib in /usr/local/lib/python2.7/site-packages (from Scrapy)
Requirement already satisfied (use --upgrade to upgrade): lxml in /usr/local/lib/python2.7/site-packages (from Scrapy)
Requirement already satisfied (use --upgrade to upgrade): pyOpenSSL in /usr/local/lib/python2.7/site-packages (from Scrapy)
Requirement already satisfied (use --upgrade to upgrade): cssselect>=0.9 in /usr/local/lib/python2.7/site-packages (from Scrapy)
Requirement already satisfied (use --upgrade to upgrade): zope.interface>=3.6.0 in /usr/local/lib/python2.7/site-packages (from Twisted>=10.0.0->Scrapy)
Requirement already satisfied (use --upgrade to upgrade): six>=1.4.1 in /usr/local/lib/python2.7/site-packages (from w3lib>=1.2->Scrapy)
Requirement already satisfied (use --upgrade to upgrade): setuptools in /usr/local/lib/python2.7/site-packages/setuptools-1.1.6-py2.7.egg (from zope.interface>=3.6.0->Twisted>=10.0.0->Scrapy)
Installing collected packages: Scrapy
Running setup.py install for Scrapy
changing mode of build/scripts-2.7/scrapy from 644 to 755
no previously-included directories found matching 'docs/build'
changing mode of /usr/local/bin/scrapy to 755
Successfully installed Scrapy
Cleaning up...
When I run /usr/local/bin/scrapy I get the usage for the command and the available commands. I noticed that I have a python2.7 and python2.7-32 in my /usr/local/bin, and I remember installing the 32 bit version because of a problem with Mavericks.
Here is the output of python /usr/local/bin/scrapy:
Traceback (most recent call last): File "/usr/local/bin/scrapy", line 3, in <module> from scrapy.cmdline import execute ImportError: No module named scrapy.cmdline
And head /usr/local/bin/scrapy:
#!/usr/local/opt/python/bin/python2.7 from scrapy.cmdline import execute execute()
Are you using Homebrew or MacPorts or something? As #J.F.Sebastian said, it sounds like you are having issues mixing the default python that comes with OS X, and one that is installed via a package manager... Try /usr/local/opt/python/bin/python2.7 -m scrapy and see if that throws an ImportError.
If that works, then you may want to consider making that python executable your default. Something like alias python2.7=/usr/local/opt/python/bin/python2.7 and then always use python2.7 instead of the default python. You can likewise just point python to the /urs/local... bit, but then you won't have easy access to the system (OS X-supplied) python if you ever needed it for some reason.
EDIT: You can force pip to install to an alternate location. The details are here: Install a Python package into a different directory using pip?. If you do indeed have extra Python folders on your system, maybe you can try directing scrapy to those, even if just for a temporary solution.
Can you post the output of the pip command? Perhaps it is failing somewhere?
Also, is it possible you have two versions of Python on your machine? Pip only installs to one location, but perhaps the version of Python on your path is different.
Finally, sometimes package names given to pip are not exactly the same as the name used to import. Check the documentation of the package. I took a quick look and the import should be lowercase:
import scrapy
When all else fails you can always set the environment variable PYTHONPATH (see Permanently add a directory to PYTHONPATH for help) to the path where you installed Scrapy. (pending you're not using virtualenv -- and if you are please specify so we can help, it's generally a good idea to provide OS too)
if you run on Ubuntu:
use the official Ubuntu Packages, which already solve all dependencies for you and are continuously updated with the latest bug fixes.
Optionally, even if it solves your problem, it is always better to install python libraries on a virtual environment, using virtualenvwrapper to keep the libraries separated, try to examine the apt-get installation log to find out what tools where added, then remove scrapy python library and reinstall it in the virtual env. using pip
It appears that the scrapy module that is installed on the Python path is an executable file that will bootstrap a Scrapy project directory for you.
The Python code in the scrapy executable looks like this:
#!/usr/bin/env python
from scrapy.cmdline import execute
execute()
That's intended to be run from the command line rather than imported into your own Python project module.
According to the documentation for the project, running the scrapy executable with this syntax:
scrapy startproject <your-project-name>
will bootstrap a Scrapy project that has the following directory structure:
your-project-name/
scrapy.cfg
tutorial/
__init__.py
items.py
pipelines.py
settings.py
spiders/
__init__.py
...
There are a number of examples in the documentation that demonstrate how you create and run your own spiders, link extractors, etc., and how to manipulate the data that you retrieve with the application. They each demonstrate the appropriate Python imports from subdirectories in the scrapy package to get you up and running.
Hope that this helps.

Categories