I have been working on some facial detection code with OpenCV, however recently I needed a fetcher from a module, face_recognition. I first tried installing it with pip install face_recognition and then with conda install...
What I eventually ended up doing is creating a separate virtual environment for Anaconda in PyCharm and I installed all the face_recognition dependencies successfully with conda install, then did pip install --no-dependencies face_recognition.
The terminal reported that it had successfully installed face_recognition, however when I try running the code, I still get the error:
ModuleNotFoundError: No module named 'face_recognition'
I have been doing research and trying so many different things for about three days now; I have no idea what else I could do.
How can I create a Conda environment with the face_recognition package?
Related
I did pip freeze and the module was there in the list. Yet when I try to import it, getting the error below:
ModuleNotFoundError: No module named 'pyttsx3'
The virtual environment is activated too.
I saw another thread regarding this same issue but it was too technical for me to understand.
What do I do now? I am a newbie to linux btw.
If you are using anaconda for virtual environment, it is possible that the pip file running your pip freeze command does not point to the pip executable within the environment. You can verify this by running which pip. If the resultant path does not contain your virtual environment name in it, it is likely that the issue is what I just mentioned above. The solution to that is to install pip inside your conda environment.
Ensure that you run the following commands after activating your conda environment.
conda install pip
now install whatever package you want using the pip install <package_name>
I tried to install OpenCV in so many ways. I tried this tutorial:
https://docs.opencv.org/master/d0/db2/tutorial_macos_install.html
I tried using conda:
conda install -c conda-forge opencv
etc. etc.
But when I type in import cv2 it says:
PyCharm Image OpenCV
Does somebody have an idea?
To install opencv you can either build it with CMake (like the link you tagged) or install a pre-built version of it (easier).
You can do the pre-built via PyCharm going to your project settings and adding the 'opencv-python' package or running pip install opencv-python
If you need both main and contrib modules you can install 'opencv-contrib-python' instead
Here's the package's page: https://pypi.org/project/opencv-python/
I'm having problems installing Adam Geitgey's face_recognition library on my Windows PC.
I followed this tutorial for installing dlib with Python bindings on windows and I've successfully installed the requirements listed there.
However, trying to install dlib with pip throws the error
setup.py install for dlib: finished with status 'error'
How can I go about resolving this?
In order for dlib (with its Python bindings) to work well for you on Windows, you need to use a Python installation whose version is 3.6 or lower.
I understand you're using the latest version of Python. If I'm correct in my assumption that you're working with Python 3.8, then you'll have to follow these steps:
Install Python 3.6 on your PC — take note of the installation path as you'll need this for creating the appropriate virtual environment.
Create a Python 3.6 virtual environment — this will serve to isolate the dependencies of your current project.
Assuming your Python 3.6 was installed to C:\Users\Mfonism\AppData\Local\Programs\Python\Python36 (like it was on my PC :)), you'll create your virtual environment thusly (from your project directory):
c:\> C:\Users\Mfonism\AppData\Local\Programs\Python\Python36\python.exe -m venv env36
venv is the Python virtual environment module.
env36 is the name of the virtual environment you're creating.
Activate the so-created virtual environment.
c:\> env36\Scripts\activate
The name of the virtual environment (env36) should now appear in the terminal.
UPDATE: IGNORE THIS BLOCK
Install your project dependencies with pip.
pip install face_recognition
If this fails, use the --no-cache-dir option to circumvent cached versions of the dependencies.
pip install face_recognition --no-cache-dir
UPDATE: DO THIS INSTEAD
You will need to install specific versions of dlib and face_recognition. And you will need to install dlib first, or face_recognition will try to install the latest version of it, and this will fail.
So:
Install dlib 19.8.1
pip install dlib==19.8.1
Then install face_recognition 1.2.2
pip install face_recognition==1.2.2
My environment:
Ubuntu 18.0.4 LTS (also tried on 19.04)
I use/need python3 (3.6.8 installed)
I need cv2, which is a model of opencv.
I tried several receipts I found on the Internet, but nothing worked.
I tried to install as pre-compiled (sudo apt-get install python-opencv) - No error, but when I try the test:
import cv2 as cv
print(cv.__version__)
I get error module not found.
The problem seems that I have installed also anaconda. The above test uses then anaconda, and cannot find the module.
Compiling from source installed for python2, but I do need python3. (The test also uses anaconda)
One of my receipts worked till the end, but with the line:
workon OpenCV-master-py3
It gaves me the error workon not found.
I tried then to install via Conda, but that wants to downgrade Conda.
Is there a way to run it without anaconda and find a replacement for
"workon OpenCV-master-py3"
For python3 you can simply do pip3 install opencv-python and it will work.
using workon
creating virtual environment
mkvirtualenv -p python3 opencv
Inside the virtual environment.
If you are only working with images
pip install opencv-python
opencv-python
If you need support for working videos
pip install opencv-contrib-python
opencv-contrib-python
If you need a non GUI opencv
pip install opencv-python-headless
opencv-python-headless
If you need to install specific version you can use == to check the available version first like
pip install opencv-python== ,then install the version you require
I'm trying to import tensorflow and I have already tried everything and in the cmd prompt, I succeeded to install tensorflow with PIP.
But when I'm trying to import tensorflow in Python, I get the following error:
Error importing tensorflow. Unless you are using bazel,
you should not try to import tensorflow from its source directory;
please exit the tensorflow source tree, and relaunch your python
interpreter
from there.
I have tried everything on the internet, but nothing seems to fix it. I have Python version 3.7.1
What is the problem and more important: how can I fix this??
First, if you have already installed tensorflow with pip, trying to install it again with conda is a bad idea. Before running the conda command, first uninstall the pip version.
pip uninstall tensorflow
That is an odd error you are seeing. Try to specify the channel you are installing from. It is available from both the anaconda and conda-forge channels
conda isntall tensorflow --channel anaconda