darkflow calls wrong version of python - python

When trying to use yolo for python I followed https://github.com/thtrieu/darkflow I got flow installed using
pip3 install .
but then, when running
flow --h
I get
File "/home/computername/.local/lib/python3.5/site-packages/darkflow/net/help.py", line 9, in <module>
import cv2
ImportError: No module named 'cv2'
When I call python I get into python 3.6 and if the import cv2 it does not give any problem, i.e., cv2 is imported.
When calling
which python
I get
/home/computername/anaconda3/bin/python
So flow does call the wrong version python. I thought, maybe I should delete the python 3.5 version on my computer, but looking for how to do that I only find warnings that I should not do that.
So my question is: what to do such that it will work?
maybe other relevant information:
which pip3
/usr/bin/pip3
and (I tried to install flow with pip first, but that did not work)
which pip
/home/bombus/anaconda3/bin/pip
I am working on Ubuntu 16.04.3 LTS

Related

ModuleNotFoundError: No module named 'simpleaudio'

Basically, I recently started Python. I'm working on a project where I need audio to play. I searched up some libraries that can play audio and tried simpleaudio. I'm using Windows and sucessfull installed simpleaudio using: pip3 install simpleaudio.
However, when I tried to use simpleaudio in my project with import simpleaudio as sa, it gives me this error:
Traceback (most recent call last):
File "d:\coding\python\python projects\random tests\soundtest.py", line 1, in
import simpleaudio as sa
ModuleNotFoundError: No module named 'simpleaudio'
Any idea what is wrong?
After I installed simpleaudio, import simpleaudio as sa worked with no errors. I've run into similar errors before, and it was always because the version of pip I was using and the Python interpreter I was using didn't match. You probably need to either switch to using the same interpreter as pip3 or install the package for whatever interpreter you're using
The most probable issue is the use of differing version of python. For instance if you use pip3 it is for python3 only
Since the module was not found try
pip install simpleaudio
and then importing again
It's possible you installed the library for python2 instead of python3. In ubuntu pip is python2 and pip3 is python3- I'm not sure if that's the case on windows or not.

error importing numpy in python 3.5

I tried installing numpy with homebrew, but instead it installed in the Python 2.7 version. I found this out by following the answer on this post: Can't import numpy
Which is very strange especially since I specifically asked for python3:
M$ brew install numpy --with-python3
Warning: homebrew/python/numpy-1.11.1 already installed
However, when I try importing it in Python 3.5 I always get the same error:
File "Dataframe.py", line 1, in <module>
import numpy as np
ImportError: No module named 'numpy'
How can I get it to work as intended? I am on mac os 10.11.3
Check that you have Python 3.5 installed by running which python3 and which python (to make sure your versions aren't mixed up).
Then, to install for Python 3, you should run pip3 install numpy. It's a good idea to use the given Python tools to install Python-related packages.

cv2 import error with caffe python

I'm trying to write my own python layer in caffe, and when I try to compile it, I keep getting this import error.
Traceback (most recent call last):
File "/home/username/caffe/layer_example.py", line 3, in <module>
import cv2
ImportError: /home/username/anaconda2/lib/python2.7/site-packages/cv2.so:undefined symbol: _ZN2cv11arrowedLineERNS_3MatENS_6Point_IiEES3_RKNS_7Scalar_IdEEiiid
I've tried to find a solution online, and changed my ~/.bashrc to look like this:
export PYTHONPATH=/home/username/caffe/python:/home/username/anaconda2/lib:$PYTHONPATH
I'm still getting the import error though. Any ideas on what the possible solution might be?
EDIT: Fixed the issue!
I uninstalled opencv(2.4.10) on conda, and installed version 2.4.9:
conda install opencv=2.4.9
conda install numpy
That fixed the error for me.
EDIT: Fixed the issue! I uninstalled opencv(2.4.10) on conda, and installed version 2.4.9:
conda install opencv=2.4.9
conda install numpy
That fixed the error for me.
sudo apt-get install python-opencv
could also be a solution.
Cuz caffe ubuntu installation guide install says you have to install
libopencv-dev
However, I observed that this package makes opencv only accessible to c++.
To use opencv with python I had to install python-opencv
I got this answer from Installing OpenCV for Python on Ubuntu, getting ImportError: No module named cv2.cv

python scikit error - no module named sklearn

When i follow the website (https://www.kaggle.com/wiki/GettingStartedWithPythonForDataScience) and type python makeSubmission.py I get the following error message :
ImportError: No module named sklearn
I think I have already successfully installed the following:
Python 3.4 for windows
sciPy,NumPy and matplotlib
setuptools
scikit-learn
PyCharm
I then opened "Python 3.4 command line" and typed import sys; print(sys.__path__),but I got the message
Traceback (most recent call last): File "<stdin>", line 1, in <module>
AttributeError: module object has no attribute '__path__'
Anyone can help?
Looks like you haven't installed scikit-learn properly. pip install -U scikit-learn should do the job. Also, I would suggest downloading the Anaconda distribution of python if you're planning to use python for kaggle contests. It takes care of all the necessary dependencies and contains all the commonly needed python packages for the contest. I found that easier than the tedious download of the dependencies. Here's the Link
The Ubuntu 14.04 package is named python-sklearn (formerly python-scikits-learn) and can be installed using the following command:
sudo apt-get install python-sklearn
If you are using PyCharm or any other IDE, then you have to install 'sklearn' separately in PyCharm tool too. In My Case I am using PyCharm, select
File Menu-> Default Settings-> Project Interpreter -> Press + button and type 'sklearn'
Press install button. Installation will be done in 10 to 20 seconds.
2nd option is if you already installed 'sklearn' using terminal then you have to set path in your PyCharm IDE.

Why do I have problems loading a module in Python3 but not in Python2?

Depending on which installation of Python I am using I have some problems to load a module. When I type
from quantecon import approx_markov
in the terminal using Python 3.4.0, the following error message is returned:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.4/dist-packages/quantecon/__init__.py", line 6,in <module>
from asset_pricing import AssetPrices
ImportError: No module named 'asset_pricing'
In the folder /usr/... as referred to above, I do however find a module called asset_pricing. (I have to admit that I additionally do not understand why the module asset_pricing interferes.)
I installed quantecon with:
pip3 install quantecon
I suspect that the problems are related to the Python version I am using. I also installed
pip install quantecon
and when I call the module approx_markov form the terminal, using Python 2.7.6 (I think this is the standard Python version of the OS I am using) I do not receive any error message. To solve the problem I already followed the instruction in the following discussion but to no avail Python3 has no acces to python2 modules (ubuntu).
The currently released version of quantecon is not Python 3 compatible; it uses relative imports and these are not supported anymore in Python 3.
The version in the source repository has been refactored and updated, and looks like it'll work with Python 3. You'll need to install that version instead:
pip3 install -U git+https://github.com/jstac/quant-econ.git
where -U tells pip3 to upgrade the package.
Note that there have been a lot of changes recently; use at your own risk. You could stick with Python 2 and wait for an official release.

Categories

Resources