Can someone please tell me how to downgrade Python 3.6.9 to 3.6.6 on Ubuntu ? I tried the below commands but didnot work
1) pip install python3.6==3.6.6
2) pip install python3.6.6
First, verify that 3.6.6 is available:
apt-cache policy python3.6
If available:
apt-get install python3.6=3.6.6
If not available, you'll need to find a repo which has the version you desire and add it to your apt sources list, update, and install:
echo "<repo url>" >> /etc/apt/sources.list.d/python.list
apt-get update
apt-get install python3.6=3.6.6
I advise against downgrading your system python unless you're certain it's required. For running your application, install python3.6.6 alongside your system python, and better yet, build a virtual environment from 3.6.6:
apt-get install virtualenv
virtualenv -p <path to python3.6.6> <venv name>
One option is to use Anaconda, which allows you to easily use different Python versions on the same computer. Here are the installation instructions for Anaconda on Linux. Then create a Conda environment by running this command:
conda create --name myenv python=3.6.6
Obviously your can use a different name than "myenv". You can then activate the environment in any terminal window:
conda activate myenv
Then you can pip install any packages you want. Some basics of anaconda environments can be found on the website's getting started page.
System information:
Ubuntu 16.04, Anaconda 1.6.9, Python 3.6.4, libopencv 3.4.1, opencv 3.4.1, py-opencv 3.4.1.
Problem definition: I just upgraded my opencv to 3.4 through anaconda and found could not import.
The import error is:
ImportError: anaconda3/lib/python3.6/site-packages/../../libopencv_dnn.so.3.4: undefined symbol: _ZNK6google8protobuf7Message25InitializationErrorStringB5cxx11Ev
The following solution works for me, although not sure why and how.
conda install -c defaults libprotobuf protobuf
conda install -c menpo opencv3
Have you tried this answer from GitHub:
Configure /usr/local/cuda/include/host_config.h as suggested.
(remove the gcc 5 error from the CUDA header host_config.h)
sudo apt-get autoremove libprotobuf-dev protobuf-compiler
then compile the protobuf-2.5.0 from src and install Please config the gcc when you
compile protobuf ./configure --prefix=/usr/local/ CC=/usr/bin/gcc
Also (GitHub user groakat mentions):
for me this problem was caused because I had protobuf installed in
anaconda. If you have protobuf installed in your anaconda environment,
you have to remove all files by hand, as conda uninstall protobuf does
not remove all the library files.
I'm trying to upgrade to Tensorflow 1.9 within a conda environment (Ubuntu 16.04). I am using python 3.6.5. When I try this:
source activate myenv
sudo -H pip install --ignore-installed --upgrade https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-1.9.0rc0-cp36-cp36m-linux_x86_64.whl
I get the error:
tensorflow-1.9.0rc0-cp36-cp36m-linux_x86_64.whl is not a supported wheel on this platform.
Seems strange because the same thing worked fine for TF 1.8
TensorFlow seems to install fine without sudo -H but then when I try:
python -c "import tensorflow as tf; print(tf.__version__)"
I get the following error:
from tensorflow.python.keras._impl.keras.backend import abs
ImportError: cannot import name 'abs'
I can't install from conda because it still has 1.8 when I check with:
conda install -c conda-forge tensorflow
With sudo you're installing locally. So, remove sudo -H to install over your Environment.
also, you need the python developer library locally:
Ubuntu: apt-get install python3-dev
RHEL/Fedora: dnf install python3-devel
Mac OS: check your environment variables or try re-installing?
Windows: check your environment variables or try re-installing?
Sometimes because of outdated pip also this can happen . Try this inside that environment and let me know
python -m pip install --upgrade pip
Try to check if conda has 1.9
conda install -c conda-forge tensorflow
I figured out that this Tensorflow is a pre-release not the complete release, as a result you can upgrade it using pip directly.
You can remove your installed release and try to install this else wait for couple of weeks after that you can directly update via conda forge or pip.
I'm having issues installing OpenAI Gym Atari environment on Windows 10. I have successfully installed and used OpenAI Gym already on the same system.
It keeps tripping up when trying to run a makefile.
I am running the command pip install gym[atari]
Here is the error:
and here is what I currently have on my system...cmake and make are both clearly installed.
A while ago I have created a fork with Windows support (devs of original repository do not merge or even comment PRs and issues). It does not require neither MSYS/Cygwin nor CMake or Zlib.
To simply install atari-py wheels (binaries) use this command:
pip install -f https://github.com/Kojoley/atari-py/releases atari_py
If you have any distutils supported compiler you can install from sources:
pip install git+https://github.com/Kojoley/atari-py.git
Test your installation with a simple example:
import gym
env = gym.make('SpaceInvaders-v0')
env.reset()
for _ in range(1000):
env.step(env.action_space.sample())
env.render('human')
env.close() # https://github.com/openai/gym/issues/893
If your got a 'scrambled' output that's most likely because your gym is outdated.
I ended up installing Bash on Ubuntu on Windows and using it to run the OpenAI Gym / Atari environment. OpenAI Gym has very limited support for Windows at the moment.
This is not fully tested, because I don't remember exactly what I did, but currently I have openAI gym running with all the atari games set up and displaying, and also matplotlib plots, all while using ubuntu on windows (WSL). In fact I have sublimetext3 and spider working too.
So take these as a guide, but I don't have "clean" environment to test them on.
First, in Windows, Google "xming" (x11 server) and download from sourceforge / install / run. This is what makes it all possible.
Now in WSL bash install the display stuff to work with xming
sudo apt-get install x11-apps
export DISPLAY=localhost:0.0
nano ~/.bashrc #(add export DISPLAY=localhost:0.0 at the end. Ctrl+X to exit/save)
sudo apt-get install gnome-calculator #will get you GTK
Now in WSL bash install Anaconda. this will involve downloading the .sh file (eg with curl -O "[the http link to latest anaconda]" and running it with bash [the file].sh. Don't use sudo when installing Anaconda.
With anaconda installed, close WSL, and restart it. Now make an environment and activate it
conda create -n gym python=3.5 anaconda
source activate gym
Now get the gym repo
git clone https://github.com/openai/gym.git
cd gym
Now install these gym dependencies mentioned on openai gym repo
apt-get install -y python-numpy python-dev cmake zlib1g-dev libjpeg-dev xvfb libav-tools xorg-dev python-opengl libboost-all-dev libsdl2-dev swig
Now install libgcc with conda
conda install libgcc
Now build gym
pip install -e '.[all]'
That's basically it. make sure Xming is running on windows, and in WSL type gnome-calculator, and it should bring up the calculator. if it doesn't, keep working on the display side. If it does, try running some of the agents in the gym examples folder.
I may have missed a couple extra dependencies along the way, but these would have been things I figured out based on error messages.
Here's the pic to keep you motivated:
EDIT: Today I ran the following command which installed Qt5 as the back end, and matplotlib is working fine with Qt5Agg as the back end (vs TkAgg). This may be helpful if you're running some thing else on WSL which needs Qt5
sudo apt-get update && sudo apt-get install qtbase5-dev
Also, to find your matplotlibrc, and command prompt type:
python
import matplotlib
print(matplotlib.matplotlib_fname())
quit()
Please note that there is NO GPU SUPPORT on ubuntu for windows. This is the top requested feature at uservoice, yet MS has it on "backlog". If you're interested, vote here
I encountered that gym now requires later version v0.1.4 of atari-py than any of other cloned repos.
Thanks to Nikita Kniazev - I ported his Windows edits to latest code from openai/atari-py and got gym working.
Use:
pip install git+https://github.com/Kojoley/atari-py.git
I had the same issue with the atari-py environment. Then I followed the steps in the Openai GitHub and then it worked.
This is the exact error that I am getting. My OS is Ubuntu 16.10.
OpenCV Error: Unspecified error (The function is not implemented. Rebuild the library with Windows, GTK+ 2.x or Carbon support. If you are on Ubuntu or Debian, install libgtk2.0-dev and pkg-config, then re-run cmake or configure script) in cvShowImage, file /feedstock_root/build_artefacts/work/opencv-3.1.0/modules/highgui/src/window.cpp, line 545
Traceback (most recent call last):
File "untitled.py", line 7, in
cv2.imshow('image',img)
cv2.error: /feedstock_root/build_artefacts/work/opencv-3.1.0/modules/highgui/src/window.cpp:545: error: (-2) The function is not implemented. Rebuild the library with Windows, GTK+ 2.x or Carbon support. If you are on Ubuntu or Debian, install libgtk2.0-dev and pkg-config, then re-run cmake or configure script in function cvShowImage
my code is:
import numpy as np
import cv2
# Load an color image in grayscale
img = cv2.imread('0002.png',0)
cv2.imshow('image',img)
cv2.waitKey(0)
cv2.destroyAllWindows()
0002.png is an image in the same directory as the program.
I first installed anaconda with python 3.5, then I installed opencv by using the command
conda install -c conda-forge opencv
I installed libgtk2.0-dev just as the error said to but I still get the same error.
Any help would be much appreciated. I've been trying to solve this for several hours.
1.The easiest way:
conda remove opencv
conda update conda
conda install --channel menpo opencv
or (for OpenCV 3.1) :
conda install -c menpo opencv3
2.And if u don't want to do this, you can try to use matplotlib .
import cv2
import matplotlib.pyplot as plt
img = cv2.imread('img.jpg',0)
plt.imshow(img, cmap='gray')
plt.show()
3.Or try to build library by your own with option WITH_GTK=ON , or smth like that.
Update - 18th Jun 2019
I got this error on my Ubuntu(18.04.1 LTS) system for openCV 3.4.2, as the method call to cv2.imshow was failing. I am using anaconda. Just the below 2 steps helped me resolve:
conda remove opencv
conda install -c conda-forge opencv=4.1.0
If you are using pip, you can try
pip install opencv-contrib-python
I have had to deal with this issue a couple of times, this is what has worked consistently thus far:
conda remove opencv
conda install -c menpo opencv
pip install --upgrade pip
pip install opencv-contrib-python
π Working method (π¨βπ¬ tested on April 19, 2019)
π These error happen because of conda.
πΉ Open Anaconda Prompt and remove conda opencv if installed
π¨βπ» conda remove opencv
π’ If you have conda env, firstly activate it conda activate <your_env_name>
β¬ After install opencv via pip (click here to offical info)
π¨βπ» pip install opencv-contrib-python
π’ if pip haven't installed, use conda install pip command.
If you installed OpenCV using the opencv-python pip package at any point in time, be aware of the following note, taken from https://pypi.python.org/pypi/opencv-python
IMPORTANT NOTE
MacOS and Linux wheels have currently some limitations:
video related functionality is not supported (not compiled with FFmpeg)
for example cv2.imshow() will not work (not compiled with GTK+ 2.x or Carbon support)
Also note that to install from another source, first you must remove the opencv-python package
For me (Arch Linux, Anaconda with Python 3.6), installing from the suggested channels menpo or loopbio did not change anything. My solution (see related question) was to
install pkg-config (sudo pacman -Syu pkg-config),
remove opencv from the environment (conda remove opencv) and
re-install opencv from the conda-forge channel (conda install -c conda-forge opencv)
conda list now returns opencv 3.3.0 py36_blas_openblas_203 [blas_openblas] conda-forgeand all windows launched using cv2 are working fine.
I followed this tutorial (OpenCV GTK+2.x error) and did the following. It worked for me :
install the packages : libgtk2.0-dev and pkg-config
cd to your opencv directory
mkdir Release
cd Release
Run the command : cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D WITH_TBB=ON -D BUILD_NEW_PYTHON_SUPPORT=ON -D WITH_V4L=ON -D INSTALL_C_EXAMPLES=ON -D INSTALL_PYTHON_EXAMPLES=ON -D BUILD_EXAMPLES=ON -D WITH_QT=ON -D WITH_GTK=ON -D WITH_OPENGL=ON ..
make
sudo make install
Notice that it is complaining for libgtk2.0-dev and pkg-config. Here is the solution. Uninstall your existing openCV installation.
conda remove opencv3
Install these packages before installing opencv-
conda install gtk2 pkg-config
Now install opencv from menpo
conda install -c https://conda.anaconda.org/menpo opencv3
If you are running inside docker then you may get this error.Solution uninstall current and install the headless one
pip install opencv-python==3.4.5.20
pip install opencv-contrib-python==3.4.5.20
If you are writing to the image and displaying it, you may need the following
apt-get update && apt-get install -y libglib2.0-0 libsm6 libxext6 libxrender1
And if you are wondering how to get the display from Docker, it is possible via X11 in your host
My ubuntu 18.04 machine is running at AWS.
What helped me was (link):
pip uninstall opencv-python
pip install opencv-python==4.1.2.30
Afterwards I got the error: " : cannot connect to X server "
Finally, I managed to make it work by installing MobaXTerm (reference here).
FYI:
I connect to AWS with WinSCP. If you connect to AWS via something like WinSCP, the MobaXTerm interface lets you connect to the "WinSCP temporary session" if you click at "Sessions", which is very convenient. The session screen basically replaces the console but allows to display the image via a pop-up window.
In case you also experience the error ASSERT: βfalseβ in file qasciikey.cpp, line 501 once cv.imshow() or similar is executed, go to the MobaXTerm interface, click Settings -> Configuration -> X11, uncheck "Unix-compatible keyboard" (reference here).
I used pip to install opencv-python. (https://pypi.org/project/opencv-python/)
1) Remove the opencv package from conda:
>> conda remove opencv
2) To your env.yml file add this:
...
dependencies:
- numpy
- pytest
...
- pip:
- opencv-python
Remove opencv from anaconda=
conda remove opencv
Then, reinstall opencv using pip:
pip install opencv
This is working for me.
My Envirment is Win10, and I added the anaconda path to the environment variables's PATHβ,the cv2.imshow worked
C:\Users\user\Anaconda3
C:\Users\user\Anaconda3\Scripts
Then restart the windows
Although this is already answered, for me conda-forge solution worked with a hack.
My workstation is a centos 6 machine, and I use conda virtual environment (anaconda 2). Create an environment
conda create --name test python=2.7
and then activate it
conda activate test
Now install opencv from conda-forge
conda install -c conda-forge opencv
Now install matplotlib in this environment (and this is hack 1)
conda install matplotlib
Let's check now imshow works or not. In a terminal, activate test environment and start python. In the interpreter, do
import cv2
import matplotlib.pyplot as plt # hack 2
img = cv2.imread('your_image_file',0)
cv2.imshow('image',img)
This should pop up a window showing image. I did not further research how this solved the case.
Note 1: You may see some error related to xkb, then in your .bashrc file add
export QT_XKB_CONFIG_ROOT=/usr/share/X11/xkb
Note 2: You may see some error related to XDG_RUNTIME_DIR, then in your .bashrc file also add
export XDG_RUNTIME_DIR=.tmp/myruntime
and define myruntime by mkdir -p .tmp/myruntime
For my system (Ubuntu 18.04) the following was working.
First:
sudo apt-get update -y
sudo apt-get install -y libgtk2.0-dev
conda create -n py35 python=3.5
conda activate py35
Then configure the environment
pip install Cython
pip install scikit-build
conda install -c anaconda cmake
pip install dlib
pip install face_recognition
pip install imutils
And finally:
pip install opencv-contrib-python
Easy with Ubuntu 18.04. It works for me:
Remove opencv-python:
pip3 uninstall opencv-python
And then re-install opencv-python:
pip3 install opencv-python
Issue was resolved.
I was able to fix it by installing a previous version of opencv-contrib-python.
I'm using Ubuntu 18