I installed python 3.4.3 and NLTK-3.0.4. When I import nltk in python, the below error appeared :
Traceback (most recent call last):
File "<pyshell#0>", line 1, in <module>
import nltk
ImportError: No module named 'nltk'
How can I solve this?
I just extract nltk.rar and then copy the folder to the below folder:
C/python34/lib
Note: before copying the folder, you should rename the name of the folder and just remove the numbers.
Before copying = nltk 3.4.3
After renaming = nltk
Following are the instructions from the nltk website.So what's the os you are using
Mac/Unix
Install NLTK: run sudo pip install -U nltk
Install Numpy (optional): run sudo pip install -U numpy
Test installation: run python then type import nltk
For older versions of Python it might be necessary to install setuptools (see http://pypi.python.org/pypi/setuptools) and to install pip (sudo easy_install pip).
Windows
These instructions assume that you do not already have Python installed on your machine.
Install python 3.4 first
Install NLTK: http://pypi.python.org/pypi/nltk
Test installation: Start>Python34, then type import nltk
Related
I am trying to create an image processing program using convolutions. I need the package scikit-image, specifically this:
from skimage.exposure import rescale_intensity
I have repeatedly installed scikit-image using pip install scikit-image in my terminal (Mac). I did this in the folder where my convolutions.py file is located (is this what is meant by the PYTHONPATH?). However, I always get an error message:
Traceback (most recent call last):
File "Convolutions.py", line 6, in <module>
from skimage.exposure import rescale_intensity
ImportError: No module named skimage.exposure
How do I solve the problem?
make sure you are installing the package on the same version of python which you are running. On a mac, python by default runs python-2.7, and the command python3 runs python-3.x. Also, pip by default installs packages to python-2.7. To install them on python3 try running
python3 -m pip install scikit-image
or simply
pip3 install scikit-image
I am trying to install Pytorch via pip on ubuntu 18.04.I have python 3.6 and my laptop is HP-Pavilion notebook 15
The installation seems to be right because i get the message:
Installing collected packages: torch, torchvision Successfully
installed torch-1.3.1+cpu torchvision-0.4.2+cpu
i run the verification code and it is ok
from __future__ import print_function
import torch
x = torch.rand(5, 3)
print(x)
However, when i close the terminal or reboot and try to run he same code i get the error:
Traceback (most recent call last):
File "torch.py", line 2, in
import torch
AttributeError: module 'torch' has no attribute 'rand'
How are you executing the python script? Which python are you using? Maybe you installed the package in a different python version?
Try to set alias to the python you want to use:
alias python=/usr/local/bin/python3.6
Then pip install the package with that python alias you will always be using.
python pip install <package name>
Python now will install the package in the python files with the alias python - heading to files: /usr/local/bin/python3.6
Let me know if the error still occurs!
Install pytorch using pip through the below command:
pip3 install torch==1.3.1+cpu torchvision==0.4.2+cpu -f https://download.pytorch.org/whl/torch_stable.html
for any reference go through the official website of pytorch.
Change your file .py to another name, you named torch.py when you import torch it will call ur torch.py
I need to install python wrapper for StanfordCoreNLP.
I have used git clone https://github.com/smilli/py-corenlp and also pip install pycorenlp and its showing success in both the cases, but when I run from pycorenlp import StanfordCoreNLP, its showing ModuleNotFoundError.
I checked its path if it installed or not. It is installed at "C:\Users\simra_000\Anaconda3\Lib\site-packages\pycorenlp" using pip
and using git clone also it is installed at "C:\Users\simra_000\py-corenlp"
from pycorenlp import StanfordCoreNLP
Traceback (most recent call last): File "", line 1, in
ModuleNotFoundError: No module named 'pycorenlp'
check if the module was installed by:
pip list
also you can add this code to install the module if it's not installed:
import pip
required_pkgs = ['pycorenlp']
installed_pkgs = [pkg.key for pkg in pip.get_installed_distributions()]
for package in required_pkgs:
if package not in installed_pkgs:
with suppress_stdout():
pip.main(['install', package])
also check the version of python that you are used to run the script and the version of pip, for example if you are using python3 and you install the module via pip (python2) the module was installed for python v.2 only
otherwise check the name of your script, so if the name of your script is pycorenlp.py the import will not work, and you need to change the name of your script
hope that helps you
I am working on a project to build a Neural Net in python from an xlrd file, and I am encountering some issues. I have installed xlrd using pip install xlrd, and pybrain by cloning the git repository and running python setup.py install both of which were successful in installing. When I try to run import xlrd or import pybrain from IDLE, it gives the error:
>>> import xlrd
Traceback (most recent call last):
File "<pyshell#0>", line 1, in <module>
import xlrd
ImportError: No module named 'xlrd'
and the same thing for pybrain. I only have python 3.5 installed. I am at the end of my rope with this, If anyone can give some insight in to why this may be happening I would be very appreciative.
Had this same problem with Python 3.6. Issue fixed by doing a PIP install of the XLRD.
pip install xlrd
Python 3.5.1 |Anaconda 4.0.0 (x86_64)on OS X 10.11.3
>>> from sklearn import pipeline, model_selection
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: cannot import name 'model_selection'
tried to:
upgrade six, sk-learn,
sudo pip uninstall python-dateutil
sudo pip install python-dateutil==2.2
pip2 install six -U
pip install --ignore-installed six
pip install --ignore-installed ipython
even reinstall the anaconda...
Did NOT fixed.
Thanks for help
_________Updata________
I have checked that my six version is the newest one (version = "1.10.0")
import sklearn
sklearn.version
'0.17.1'
I found that there is no folder name "model_selection" in sklearn folder. But there is this folder in https://github.com/scikit-learn/scikit-learn/tree/3078d7d611329c46777d4004a1185a3626558efe/sklearn.
After install the dev version by
$ pip install git+git://github.com/scikit-learn/scikit-learn.git
Successfully installed scikit-learn-0.18.dev0
And then run a script which runs successfully in 0.17.1, it shows error:
from .pairwise_fast import _chi2_kernel_fast, _sparse_manhattan
ImportError: dlopen(/Users/Username/anaconda3/lib/python3.5/site-packages/sklearn/metrics/pairwise_fast.cpython-35m-darwin.so, 2): Library not loaded: libmkl_intel_lp64.dylib
Referenced from: /Users/Username/anaconda3/lib/python3.5/site-packages/sklearn/metrics/pairwise_fast.cpython-35m-darwin.so
Reason: image not found
What version of scikit-learn are you using? It looks like the latest, when I install for Python 3.5, is 0.17.1. Checking in the console:
import sklearn
sklearn.__version__
'0.17.1'
According to the documentation for this version that "model_selection" package doesn't exist. It does exist in the dev version. This should be why it is complaining.