I am trying to import opencv for webcam capturing and Keras to use AI, however, it returns an error showing that the module isn't found.
I used both pip install opencv-python and python -m pip install opencv-python but I still cannot import it.
(I'm using python 3.9.6)
You might have python 2.x installed on your machine and is set as default for your pip. You could check this by running pip --version on your terminal and it should show you which version of python it is using. If it shows python 2.x, then you could use pip3 or python3 instead to install your package as you mentioned that you are using python 3.9.6 for your project environment.
For future use, you could set python 3 as your default for pip. You could follow the steps given here: How to override the pip command to Python3.x instead of Python2.7?
Cheers!
Related
I'm trying to install scikit-learn with pip by using pip install scikit-learn
and I got this message:
DEPRECATION: Python 2.7 reached the end of its life on January 1st,
2020. Please upgrade your Python as Python 2.7 is no longer maintained. pip 21.0 will drop support for Python 2.7 in January 2021.
More details about Python 2 support in pip can be found at
https://pip.pypa.io/en/latest/development/release-process/#python-2-support
pip 21.0 will remove support for this functionality.
WARNING: The scripts f2py, f2py2 and f2py2.7 are installed in '/Users/my_name/Library/Python/2.7/bin' which is not on PATH.
Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
However, when I type python --version it says that my version is 3.7.4. Are python 2.7 and 3.7 both installed on my computer then? If so, is there a way I can get rid of 2.7? Also, I still get a ModuleNotFoundError when I do from sklearn.cluster import MeanShift in the mu_editor. I think it's because pip is installing the modules to the python 2.7 directory or something, instead of the python 3.7.4 directory that the mu_editor is connected to. Is there any way I can install the packages to the python 3.7.4 directory instead of the 2.7 one?
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.
plz use this command
pip install -U scikit-learn
In order to check your installation you can use
python -m pip show scikit-learn # to see which version and where scikit-learn is installed
python -m pip freeze # to see all packages installed in the active virtualenv
python -c "import sklearn; sklearn.show_versions()"
see https://scikit-learn.org/stable/install.html
I am trying to update the module vpython to the most current version. I run:
pip3 install --user vpython --upgrade
in a Jupyter terminal. This gives the error:
ERROR: jupyter-server-proxy requires Python '>=3.5' but the running Python is 3.4.2
But when I run:
python3 --version
it returns:
Python 3.5.2 :: Anaconda 4.1.1 (64-bit)
Is there something going wrong with the installed Python3 kernel for Jupyter?
Change the environmental variable in your control panel just a simple conflict between python 3.4 and 3.5 this will surely solve your issue.
The issue is that you are using pip3 which is not always tied to the specified python you are trying to run. pip is a module installed with each python3 instance, so to specify it to install to a python environment, use the -m flag:
python -m pip install <module>
Where python is the python that you expect. For instance, if you want it to run against the installation that you use through python3, then you would do python3 -m pip install <module>. This makes things easy to track, since if you want to see which python you are installing to, you can use python -m pip -V. On my machine that outputs:
pip 19.3.1 from /Users/mm92400/anaconda3/lib/python3.6/site-packages/pip (python 3.6)
My mac came with default python 2.7 and i installed python 3 now i am using pycharm and anaconda setup. Problem is when i try to install "keras" or any other package in python 2.7 so i change pycharm interpreter to --> python 2.7 but when i install keras from terminal by typing "pip install keras" and it install successfully but when i try to import keras from python 2.7 it says no module name keras and so i think it install in python 3. My question is how can i install packages in python 2.7 ?
As you have two different versions of python, you will also have two versions of pip.
where pip
should return the locations of the different versions of pip. Type the full path to the version of pip that you want instead of just "pip":
C:\users\jbloggs...\pip.exe install keras
You can specify python version when installing
pip2 install any-package
Install using
sudo python -m pip install keras
this way the package will be installed with the chosen python interpreter's pip
I'm trying to follow the tutorial on here: http://pythonhosted.org/airflow/tutorial.html
but i'm using a mac, and so i had to install python via brew, which then comes with pip, which i used to install airflow. However, that didn't quite work either, so i then tried to create a virtualenv for which i tried to install airflow and it is still giving me this ImportError: No module named mako.util
not sure if it matters, but here's my setup:
(airflow) [davidtian: airflow]$ python --version
Python 2.7.12
(airflow) [davidtian: airflow]$ pip --version
pip 8.1.2 from /Users/someone/Desktop/blah/airflow/airflow/lib/python2.7/site-packages (python 2.7)
(airflow) [davidtian: airflow]$
How do i install this mako.util module?
Finally figured it out. after trying a bunch of things. for one, the python that comes with Mac apparently doesn't work very well. you have to brew install python instead. with that python, it comes with pip by default
i had to actually sudo pip uninstall airflow and then install it again.
I installed graph-tool on ubuntu. When trying to import it in iPython I get an error:
ImportError: No module named graph_tool.all
As I read in other posts it might be possible that I used a different version of python for installing graph-tools than the system version I'm using. My question is now, how do I check which version graph-tool is installed with and how do i change this in order to import it?
Thanks for any advice!
If you install using pip you can check
pip -V
result (for example)
pip 8.0.2 from /usr/local/lib/python3.5/dist-packages (python 3.5)
You should have pip, pip2, pip2.7, pip3, pip3.4, etc. to install with different Python.
(in bash write pip and press tab twice to see all programs started with pip)