from libsvm import svmutil
ImportError: No module named libsvm
I have the module libsvm installed. Because when I run pip3 install libsvm, I see this:
Requirement already satisfied: libsvm in /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages (3.23.0.4)
So what's causing the error?
make sure you are using the same python version, when you install the library and you run it. fyi, pip3 is for python 3.
my suggestion is create new virtual environment and activate then install all library that needed, then run your app from there.
Try the followings, it may solve the problem:
0- Run your code with Python version 3 and above. (python3 yourFile.py in the terminal)
1- pip3 install libsvm
2- pip install -U libsvm-official
Related
I am trying to use scipy but when I import it with import scipy, it says "no module named scipy. I have used pip list to see if it is installed and it is, and i have tried pip install scipy but it just said that it was already installed. Does anyone know how to fix this?
SOLVED: ran the code with python3 instead of python
it is possible you have 2 versions of python installed, python2.7 or python3.x .. when you install stuff with pip and want to use it for a specific python version:
pip install scipy is for python 2.7, so its "python" in the terminal and "python x" to run scripts
pip3 install scipy is for python 3, so its "python3" in the terminal and "python3 x" to run scripts
in your case, you would be calling scripts like:
python pythonFile.py
you would be installing packages like:
pip install package
and you would be using python in the terminal with "python"
if that still doesn't work, for me solving that problem was updating numpy. not sure if it would be the same with you. hope this helped
Currently I'm trying to install tensorflow with pip, I've used the following command to install it with:
pip3 install --user --upgrade tensorflow which after installing returns Successfully installed tensorflow-2.5.0. But when I install I get a lot of notices "Requirement already satisfied" but I'm unsure if this is normal or not.
I have a following local python file on my Windows 10 computer called test.py and inside is a simple import
test.py
import tensorflow as tf
When I run python I get the following error:
import tensorflow as tf
ModuleNotFoundError: No module named 'tensorflow'
When I run pip3 list I can see that the module tensorflow is there, but importing it does give the error. It seems to happen with other modules too, as I've tried installing pymongo and it gave me the same error.
What I've tried
Uninstalling, re-installing python
Uninstalling and re-installing tensorflow
Python3 version: 3.9.5
Pip3 version: 21.1.1
I would try python3 -m pip install tensorflow. Running pip as a module ensures the versions are the same and can help with compatibility.
Most probably you have installed tensorflow on python3(guessing after seeing pip3 command) but you are running script on python2 (guessing after seeing "When I run python").
Assuming you aren't using virtualenv
Try running
python3 test.py
If this didnt help then try below command.
python3.x test.py # where x could be your minor version Ex: python3.6/python3.7
I am trying to import 'sklearn' using Python 3.4.3 on a Raspberry Pi 3 running Raspian.
I downloaded microconda3, which includes all the necessary modules to use scikit.
However, when I attempt to import 'sklearn' in IDLE, I receive an error stating that there is no module named 'sklearn'.
Try starting fresh and reinstall all of the necessary modules through miniconda3. Maybe the scikit-learn included on that install did not work.
You can then try
sudo apt-get install python3-scipy python3-sklearn
You can install the module with the following command using pip:
pip install -U scikit-learn.
See: Scikit-learn Docs
My OS is Ubuntu, and I've followed the official installation guide to install lightgbm. However, when I import it, this error is raised:
ImportError: No module named lightgbm
How can I solve this?
Do I also need to go to /python-package folder to run setup.py after running those linux commandlines?
I had the same problem, and solved running the installation directly on the notebook
!pip install lightgbm
Besides running those linux command lines. I also need to go to /python-package then run 'python setup.py install'.
conda install -c conda-forge lightgbm solved the problem for me
you need just run in a notebook cell before importing
For Windows users, VC runtime <https://go.microsoft.com/fwlink/?LinkId=746572> is needed if Visual Studio (2015 or 2017) is not installed.
Install wheel <http://pythonwheels.com> via pip install wheel first. After that download the wheel file and install from it:
pip install lightgbm
The following should do the trick:
export PATH=/usr/local/bin/anaconda3/bin${PATH:+:${PATH}}
PYTHONPATH=$PYTHONPATH:/usr/local/bin/anaconda3/lib/python3.6/site-packages
Note that you might need to change the paths if you are using a different Python version.
Thank you for above question and answers, had a similar issue.
Problem:
After successfull install of lightgbm, I was getting the error ImportError: No module named 'lightgbm' (in Jupyter Notebook on Google Cloud's Notebook Instance in AI Platform project).
Issue:
Realized that the install of lightgbm was in Python 2.7 even when the notebook was running in Python 3 (path: './.local/lib/python2.7/site-packages').
Solution:
The error was gone after the Jupyter Notebook was set to run on Python 2 instead of Python 3.
within Jupyter Notebook cell is: try running
import sys
!{sys.executable} -m pip install lightgbm
With python try, from pypi.org, this line
pip install lightgbm
or
pip3 install lightgbm
Also, you can try this one if you use anaconda
conda install lightgbm
I am using vagrant to run my python environment. In my data models I am using django-picklefield module.
when I run my server it says
ImportError: No module named picklefield.fields.
I tried to uninstall and install the picklefield module. Still having the same problem.
You should be able install via:
/[your python install directory]/bin/pip install django-picklefield
If you do this directly instead of a general pip call to install django-picklefield, that will ensure that it is installed on the correct version of Python.
Based on your description my best guess is that you have multiple versions of Python installed, and that your install/uninstall is happening on the wrong one.