how to check which version of nltk, scikit learn installed?
import nltk
is Python syntax, and as such won't work in a shell script.
To test the version of nltk
and scikit_learn
, you can write a Python script and run it. Such a script may look like
import nltk
import sklearn
print('The nltk version is {}.'.format(nltk.__version__))
print('The scikit-learn version is {}.'.format(sklearn.__version__))
# The nltk version is 3.0.0.
# The scikit-learn version is 0.15.2.
Note that not all Python packages are guaranteed to have a __version__
attribute, so for some others it may fail, but for nltk and scikit-learn at least it will work.
Installing scikit-learn with pip: are there multiple python versions installed on my computer?
First, use python -v
to check default python installation. If it is the version you are using, continue with python
instead of python3
.
Now run python3 -m pip install scikit-learn
If you are on a Mac, DO NOT DELETE PYTHON 2.7. It is needed for your system to run properly.
How do I check the versions of Python modules?
Use pip
instead of easy_install
.
With pip, list all installed packages and their versions via:
pip freeze
On most Linux systems, you can pipe this to grep
(or findstr
on Windows) to find the row for the particular package you're interested in.
Linux:
pip freeze | grep lxml
lxml==2.3
Windows:
pip freeze | findstr lxml
lxml==2.3
For an individual module, you can try the __version__
attribute. However, there are modules without it:
python -c "import requests; print(requests.__version__)"
2.14.2
python -c "import lxml; print(lxml.__version__)"
Traceback (most recent call last):
File "<string>", line 1, in <module>
AttributeError: 'module' object has no attribute 'version'
Lastly, as the commands in your question are prefixed with sudo
, it appears you're installing to the global python environment. I strongly advise to take look into Python virtual environment managers, for example virtualenvwrapper.
Difference between scikit-learn and sklearn
You might need to reinstall numpy. It doesn't seem to have installed correctly.
sklearn
is how you type the scikit-learn name in python.
Also, try running the standard tests in scikit-learn and check the output. You will have detailed error information there.
Do you have nosetests
installed? Try: nosetests -v sklearn
. You type this in bash, not in the python interpreter.
Scikit-Learn Version Not Updating
By prepending sudo
in the pip
call, you are referring to the system's python instead of a virtualenv one.
If you are within a virtualenv, simply do pip install -U scikit-learn
(i.e. drop the sudo).
EDIT:
OP installed sklearn with apt, sudo apt remove --purge python-sklearn
and reinstall sklearn with pip
solved it.
Related Topics
Python Requests, How to Specify Port for Outgoing Traffic
Install Scipy with Mkl Through Pip
Read, Highlight, Save PDF Programmatically
How to Run Multiple Subprocesses via Fork()
How to Find Out the Date of the Last Saturday in Linux Shell Script or Python
Trouble Connecting to Phantomjs Webdriver Using Python and Selenium
Python Multiprocessing Pool.Apply_Async with Shared Variables (Value)
How to Download a Single File from Gitlab
Filter Options for Sniff Function in Scapy
How to Make Shell Output Redirect (>) Write While Script Is Still Running
Need a Way to Determine If a File Is Done Being Written To
Trouble Importing Tabulate in Python 3.4
Opening Filenames with Colon (":") in Windows 7
Copy Data from the Clipboard on Linux, MAC and Windows with a Single Python Script
How to Get the Python Call Stack with the Linux Perf
How to Make Python Script Press 'Enter' When Prompted on Shell