Anaconda/OpenCV: Installing with Tracking features - python

Hopefully someone can point me in the right direction here.
I'm using the latest release of Anaconda (Python 2.7). I would like to use it with OpenCV with the tracking features. I've tried various versions of the cv2.pyd file including 3.0, 3.1, 3.2, 3.3 and 3.4. However, the examples I've found use one of the following commands which are not found in the module.
tracker = cv2.Tracker_create(tracker_type)
or
tracker = cv2.TrackerKCF_create()
The usage of either of these depends which OpenCV version is being used. However, neither of them work, both with the following error.
'module' object has no attribute 'Tracker_create / or TrackerKCF_create'
All of the other features in OpenCV seem to work fine.
Is the cv2.pyd file I'm extracting from the Windows OpenCV install limited to certain features?
If I use the following in the Anaconda Prompt
conda install -c menpo opencv3
it installs the tracking features I need. However, it installs v3.1 of OpenCV which is known to have bugs with the tracking features. Ideally I wan't v3.4 of OpenCV.
Any help would be appreciated.

If you're using Anaconda then it would be wise to use it's environment management tools. Create an environment.yml file with the following contents:
environment.yml using conda-forge/opencv & python 3.6
name: opencv-env # any name for the environment
channels:
- conda-forge
dependencies: # everything under this, installed by conda
- python=3.6
- opencv=3.4
- pip: # everything under this, installed by pip
- future
environment.yml using pip/opencv-python & python 3.6
name: opencv-env # any name for the environment
channels:
- defaults
dependencies: # everything under this, installed by conda
- python=3.6
- pip: # everything under this, installed by pip
- future
- opencv-python>=3.4
How to install the environment?
conda create --force -f environment.yml
How to activate the environment?
source activate opencv-env
Once you've activated the environment, you can check the version of opencv.

Related

Problems installing python packages on Mac M1

I want to install python packages listed in the requirements file of my github repo. However, I have problems installing those python packages into my conda environment.
First of all, I installed conda with Miniforge3-MacOSX-arm64 which supports the M1 with arm64 architecture. However, some specific python packages like onnxruntime I wasn't able to install, because I encountered error messages like that:
ERROR: Could not find a version that satisfies the requirement onnxruntime
ERROR: No matching distribution found for onnxruntime
I assumed that for those specific python packages there is no support yet for the M1.
Therefore, I pursued another approach. I set the settings of Terminal to "Open with Rosetta". The plan is to install the applications of the intel x86_64 architecture and let Rossetta create the binaries to let run on arm64. Then I uninstalled miniforge for arm64 and installed miniforge for x86_64 named Miniforge3-MacOSX-x86_64. With that setup I was able to install all listed python packages of the requirement file and with pip freeze I can also confirm that they have been installed. However, I am somehow not able to use those python packages. For instance if I want to run pytest I get the following error:
zsh: illegal hardware instruction pytest
I assumed Rossetta takes care of that, that I can use applications for x86_64 also on arm64. But somehow it doesn't work. I tried a lot of different things and am out of ideas.
Does anyone know what the problem is? I would be also thankful for advice and suggestions how to properly set up a python environment on Mac M1.
I had the same problem back in 2days ago, I'm using m1 pro. I was trying to install the python packages only using pip but I got a numbers of errors, then I decided to install with conda.
In my case it worked, here is what I've done so far is:
First Enable the open with rosetta in your zsh.
And then,
# create environment in conda
conda create -n venv python=3.8 # with your python version
# activate
conda activate venv
and visit the conda website to look for the packages:
check packages
For suppose if you are looking for pytest packages then you can search it, and you'll get a result like this, with the available package and channel.
You need to enable that specific channel to get that package with this command:
# config channel
conda config --append channels conda-forge # available channel name
# then install
conda install --yes --file requirements.txt
Make sure, your have the same version of pytest in your requirements.txt file. (eg:pytest==6.2.5)
Hope this should work, if not try to install it with pip like:
pip install -r requirements.txt
after environment enable.

Anaconda Navigator installing an older version (0.7.3) of Sympy

I'm new to Python and just downloaded Anaconda Python. Anaconda comes with Sympy 1.4 but I need to use Sympy 0.7.3.
I see that Anaconda Navigator has the option to replace 1.4 with other versions (specifically 1.1.1 or 1.2 or 1.3) however 0.7.3 is not in the list. I have found an archive with version 0.7.3 at https://anaconda.org/anaconda/sympy/files?version=0.7.3 and I tried adding that path to the channel list but it was flagged as an invalid channel. How do I import Sympy 0.7.3?
I'm running on Windows and am doing all this because I want to run Symoro.
Any help is very much appreciated!
Anaconda recently dropped support for what was called their free channel and this has resulted in many older packages becoming inaccessible by default. Unfortunately, that older version of SymPy is in that part of the repository. You have two options:
Download the tarball and install from that.
Enable access to the free channel.
SymPy 0.7.3 is only available for Python 2.6, 2.7, or 3.3. If you want to use Python 2.7 then downloading should be the easiest route; for Python 3.3 (or 2.6 for some reason), I'd recommend the latter option, because almost all the other packages for these versions are also in the free channel.
In either case, you will use Anaconda Prompt (or another shell) and need to create a new environment, because it is generally a bad idea to force major changes into the Anaconda base environment.
Option 1: Installing from the Tarball
First, you need create the new Python 2.7 env. Let's call it my_env:
conda create --name my_env python=2.7
If there is other software you know you'll want, then you can also include that after the python=2.7.
Download the file sympy-0.7.3-py27_0.tar.bz2 (this is the win-64 version - others are where you pointed out already).
Install it:
conda install -n my_env sympy-0.7.3-py27_0.tar.bz2
Test your new env:
conda activate my_env
python -c "import sympy; sympy.doctest('polynomial')"
Option 2: (Temporarily) Enabling the free Channel
Just note that I wouldn't generally recommend keeping this enabled since it really tends to slow down the Conda solver (see "Why we removed the free channel in Conda 4.7). I'll recommend disabling it again (step 3), but keep in mind that if you ever need to make adjustments to your SymPy 0.7.3 env, you'll probably need to re-enable it.
Enable the free channel:
conda config --set restore_free_channel True
Create your new env:
conda create --name my_env python=3.3 sympy=0.7.3
Disable free channel
conda config --set restore_free_channel False
Test your SymPy env
conda activate my_env
python -c "import sympy; sympy.doctest('polynomial')"
Have a look at installing packages on anaconda
To install a specific version of a package such as SciPy:
conda install scipy=0.15.0
So try
conda install sympy=0.7.3
Seems to do the trick for me. It's in the default conda channel so you shouldn't need to change or add a channel

How to set the environment default python in anaconda?

It makes me crazy, In anaconda I create the environment with the defualt iterpreter python3.4 Next I install pytorch 0.4.1
conda install pytorch=0.4.1 cuda80 -c pytorch
After this I found that the pytorch was installed in python3.6!
And the environment defualt interpreter is chaged from python3.4 to python3.6.
I am very confused what happend ? How shoud I fix it back? change defualt python back to python3.4? Hope some one could help me.
The commands I typed in are as follows:
conda create -n pointgen python=3.4 ipykernel
source activate pointgen
conda install pytorch=0.4.1 cuda80 -c pytorch
Thats all. What Novak said is right, there is remaining question is how could I manually change the python version from 3.6 back to 3.4, is there any config file I can deal with?
As you can see here there is no version of pytorch for python3.4... The default version of pytorch is for python3.6 and that is the version you installed installed. In the process anaconda prompts you that it will have to upgrade/downgrade some package versions and there is probably the the line in which it says it will upgrade python to 3.6

Installing Tensorflow - not supported wheel

I have installed Python version 3.5 and 3.6 and anaconda.
The following error occures when trying to install tensorflow following the steps here
https://www.tensorflow.org/install/install_windows
unsing anaconda
(tensorflow) C:> pip install --ignore-installed --upgrade https://storage.googleapis.com/tensorflow/windows/cpu/tensorflow-1.0.1-cp35-cp35m-win_amd64.whl
tensorflow-1.0.1-cp35-cp35m-win_amd64.whl is not a supported wheel on this platform.
As I am new to Python, I do not know how to circumvent this probelm.
I am using Win10 with 64bit.
Thanks a lot and best,
Martin
I ran into the same difficulties with the same error. It seems to be that Python 3.6 isn't immediately supported and found a sort of workaround here (note that this involves installing Python 3.5 which I did not already have installed, I don't know if this should be done a different way if its already installed):
If you are using anaconda distribution, you can do the following to use python 3.5 on the new environment "tensorflow":
conda create --name tensorflow python=3.5
activate tensorflow
conda install jupyter
conda install scipy
pip install tensorflow
\# or
\# pip install tensorflow-gpu
It is important to add python=3.5 at the end of the first line, because it will install Python 3.5.
If you've already created the tensorflow environment (the conda create step), you'll have to delete it and start over. Otherwise, you'll run into an error "CondaValueError: Value error: prefix already exists: C:\[your environment location]" (If you run into the unsupported wheel error, then you probably created the environment already.)
To delete your previous environment, according to the Conda Cheat Sheet, you first deactivate from (tensor flow) if needed by calling deactivate, then call conda remove --prefix ~/bioenvcopy --all. For ~/bioenvcopy I believe you use the tensorflow environment path. The location can be found by calling conda info --envs (citing the cheat sheet once again). Mine, for example, was conda remove --prefix ~/Anaconda3/envs/tensorflow
I successfully used this work around on Windows 10.
This solution probably be obsolete when 3.6 is supported.
Creating the tensorflow env without the correct python version did not work for me. So I had to do the following, which worked...
>deactivate tensorflow # start by deactivating the existing tensorflow env
>conda env remove -n tensorflow # remove the env
>conda create -n tensorflow python=3.5
>activate tensorflow
i had the same problem in windows 10 and python 3.6
so i navigated to anaconda navigator ( just search anaconda navigator in start search).
in the Environment tab you can create/delete your environments.
just create an environment, name it tensorflow and choose python 3.5 as python version.
then you can activate tensorflow in your command line:
activate tensorflow
and install tensorflow with :
pip install tensorflow #or tensowrlow-gpu
I had the same problem after hours of searching, I found that to save yourself from installing error problem in tensorflow. The convenient way for installing tensorflow is by creating a virtual environment in Conda with python 3.5.2 and using Conda-forge. This is done by running this commands:
conda create -n tensorflow python=3.5.2
activate tensorflow
conda config --add channels conda-forge
conda install tensorflow
Try installing the 64-bit version of Python 3.6.8:
https://www.python.org/ftp/python/3.6.8/python-3.6.8-amd64.exe
I was getting the same error with the same OS and that's what fixed it. Apparently Tensorflow doesn't work on 32-bit Python even if your OS is 64-bit.
Try uninstalling everything (python, etc.) and try again using the cmd only, not git bash or PowerShell.
https://github.com/tensorflow/tensorflow/issues/9264
In Anaconda prompt, follow the instruction on Installing with Anaconda,
conda create -n tensorflow
activate tensorflow
Then the third step is a little different, try:
pip install tensorflow
This should work, good luck! If anything wrong happens, please let me know.

Tensorflow and Anaconda on Ubuntu?

On my Ubuntu 14.04, I have installed tensorflow, using "pip", as specified in the Tensorflow Installation instructions and I made sure it was working by importing it in python and it did work.
Then, I installed Anaconda and it changed my .bashrc file by adding the following line to it:
export PATH="/home/sonny/anaconda2/bin:$PATH"
But because of this change, now it looks into the PATH above, which doesn't contain tensorflow. now I can't import tensorflow in my python code.
What is the proper way to extend the $PATH environment variable so that it stays using everything from anaconda2 but it becomes able to import "tensorflow"?
I solved the problem but in a different way!
I found a link where the tensorflow.whl files were converted to conda packages, so I went ahead and installed it using the command:
conda install -c https://conda.anaconda.org/jjhelmus tensorflow
and it worked, since the $PATH points to anaconda packages, I can import it now!
Source is here
Since v0.10.0, tensorflow is a community maintained conda package in the conda-forge channel. Hence, it can be installed directly with the following command:
conda install -c conda-forge tensorflow
The instructions on the TensorFlow documentation has also been updated.
To facilitate future updates, it is probably a good idea to add conda-forge channel into your conda config:
conda config --add channels conda-forge
In fact, tensorflow=0.10.0rc0 was recently added onto the Anaconda default channel and will be installed instead if the conda-forge channel is not specified:
conda install tensorflow
I had the same problem and decided it was easiest to start over, install Anaconda first and then TensorFlow after that.
I suspect that pip is giving you a TensorFlow installation in cpython, not anaconda.
How about a virtualenv?
# Create env
$ virtualenv --python=/path/to/anaconda /path/to/your/env
# Activate env
$ source /path/to/your/env/bin/activate
# Install Tensorflow
$ pip install https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-0.5.0-cp27-none-linux_x86_64.whl
Install tensorflow from the following command. Conda will take care of the installation process.
conda install -c conda-forge tensorflow
I solved the problem using this:
conda create --name=tensorenv python=3.4
source activate tensorenv
Actually, the TensorFlow Official website made every detail of installing.
The Operation System Windows, Mac OS, Ubuntu; the environment with GPU or just CPU, every single detail of problems you may come up with.
Check this out
Installing TensorFlow on Ubuntu with Anaconda
you will not regret.
Once you visit that you may also find like
Installing TensorFlow on Windows with Anaconda

Categories

Resources