I am struggling to make basic plots in matplotlib. It looks like I'm not installing tkinter correctly, which I understand should be installed from the --with-tcl-tk flag. What could be causing my error? How can I better diagnose this problem? Downloading the ActiveState tkinter has not helped me.
I uninstalled then reinstalled everything I thought was relevant. No errors were raised by brew.
$ brew uninstall python
$ brew uninstall matplotlib numpy --force
$ brew install python --with-tcl-tk
$ brew install numpy matplotlib --with-tcl-tk
However, I get an error when I import pyplot:
$ python
Python 2.7.11 (default, Dec 22 2015, 12:47:31)
[GCC 4.2.1 Compatible Apple LLVM 7.0.2 (clang-700.1.81)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from matplotlib import pyplot
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.7/site-packages/matplotlib/pyplot.py", line 109, in <module>
_backend_mod, new_figure_manager, draw_if_interactive, _show = pylab_setup()
File "/usr/local/lib/python2.7/site-packages/matplotlib/backends/__init__.py", line 32, in pylab_setup
globals(),locals(),[backend_name],0)
File "/usr/local/lib/python2.7/site-packages/matplotlib/backends/backend_tkagg.py", line 6, in <module>
from six.moves import tkinter as Tk
File "/usr/local/lib/python2.7/site-packages/six.py", line 199, in load_module
mod = mod._resolve()
File "/usr/local/lib/python2.7/site-packages/six.py", line 113, in _resolve
return _import_module(self.mod)
File "/usr/local/lib/python2.7/site-packages/six.py", line 80, in _import_module
__import__(name)
File "/usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk/Tkinter.py", line 39, in <module>
import _tkinter # If this fails your Python may not be configured for Tk
ImportError: No module named _tkinter
>>>
This is a little faster (and hopefully safer) than the uninstall method...
1) Ensure you have Brew's Tcl/Tk installed (it is kept separate from the MacOS one)
brew install tcl-tk
2) Now recompile Python with Tcl/Tk enabled
brew reinstall python --with-tcl-tk
In my case I solved this by uninstalling and reinstalling Python using homebrew. I hope there is a better solution that someone else can provide...
$ brew uninstall python#2
Uninstalling /usr/local/Cellar/python#2/2.7.14_3... (4,324 files, 77.4MB)
$ brew install python#2
==> Downloading https://homebrew.bintray.com/bottles/python#2-2.7.14_3.el_capita
######################################################################## 100.0%
==> Pouring python#2-2.7.14_3.el_capitan.bottle.2.tar.gz
==> /usr/local/Cellar/python#2/2.7.14_3/bin/python -s setup.py --no-user-cfg ins
==> /usr/local/Cellar/python#2/2.7.14_3/bin/python -s setup.py --no-user-cfg ins
==> /usr/local/Cellar/python#2/2.7.14_3/bin/python -s setup.py --no-user-cfg ins
==> Caveats
Pip and setuptools have been installed. To update them
pip install --upgrade pip setuptools
You can install Python packages with
pip install <package>
They will install into the site-package directory
/usr/local/lib/python2.7/site-packages
See: https://docs.brew.sh/Homebrew-and-Python
==> Summary
🍺 /usr/local/Cellar/python#2/2.7.14_3: 4,669 files, 82.4MB
Pip kept everything, and the venv I was using was also still intact.
Related
I have darknet and opencv4.2.0 with Ubuntu 18.04
however I couldn't import CV2 while using python (darknet works well)
when i use sudo pip3 install opencv-python
terminal shows
Installing through navigator doesn't work either
There are many steps while installing OpenCV on Raspberry pi . Is there any chance to install by using a single command. I tried sudo apt-get install python3-opencv but that doesn't work.
The main one liner is with pip The Python Package Installer but to make it work you also need some dependencies that may or may not be installed already from other related tools.
$ pip3 install opencv-python
$ sudo apt-get install libatlas-base-dev libjasper-dev libqtgui4 python3-pyqt5 libqt4-test libilmbase-dev libopenexr-dev libgstreamer1.0-dev libavcodec58 libavformat58 libswscale5
In addition with the current newest version you need to set an env variable to run it, LD_PRELOAD=/usr/lib/arm-linux-gnueabihf/libatomic.so.1.2.0 referenced issue
$ LD_PRELOAD=/usr/lib/arm-linux-gnueabihf/libatomic.so.1.2.0 python3
Python 3.7.3 (default, Apr 3 2019, 05:39:12)
[GCC 8.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import cv2
>>>
If you are really opposed to that you can use a previous version that doesn't have this issue. Don't forget to uninstall the other version if you already installed it pip3 uninstall opencv-python
$ pip3 install opencv-python==4.1.0.25
On a newly flashed 2019-09-26-raspbian-buster-lite img after adding ssh access and connecting that way.
system update and install pip3
$ sudo apt-get update
$ sudo apt-get upgrade
$ sudo apt-get install python3-pip
version check
$ python3 --version
Python 3.7.3
$ pip3 --version
pip 18.1 from /usr/lib/python3/dist-packages/pip (python 3.7)
install openCV and check version
$ pip3 install opencv-python
$ pip3 freeze | grep opencv-python
opencv-python==4.1.1.26
test and fail,
$ python3
Python 3.7.3 (default, Apr 3 2019, 05:39:12)
[GCC 8.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import cv2
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/pi/.local/lib/python3.7/site-packages/cv2/__init__.py", line 3, in <module>
from .cv2 import *
ImportError: libwebp.so.6: cannot open shared object file: No such file or directory
install dependencies
$ sudo apt-get install libatlas-base-dev libjasper-dev libqtgui4 python3-pyqt5 libqt4-test libilmbase-dev libopenexr-dev libgstreamer1.0-dev libavcodec58 libavformat58 libswscale5
test with env variable set
$ LD_PRELOAD=/usr/lib/arm-linux-gnueabihf/libatomic.so.1.2.0 python3
Python 3.7.3 (default, Apr 3 2019, 05:39:12)
[GCC 8.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import cv2
>>>
The easiest way to do this is using .whl files. When you want to install a package with pip, it searches for a precompiled version of that package that is compatible with your system.
In your case, pip is looking for an OpenCV Python package compatible with armv7l platform, if it cannot find a precompiled .whl file to install, it tries to download the source as .tar.gz and compile it by itself on Raspberry Pi (which is a real pain.)
armv7l compatible .whl files are available for OpenCV Python now and you can use pip to install it directly with pip install opencv-python command but sometimes pip tries to install the latest package and sometimes it is not armv7l compatible. I suggest you check packages and put version specifications to the command.
To handle this situation a lot easier with installations of prerequisites and preparation of the installation environment; you can use complete guides like in this blog post for beginners
As above, trying to install opencv-python.
Normally this would be a simple pip install opencv-python, but it doesn't seem to work. Instead, opencv install to the miniconda directory
/home/pi/miniconda3/lib/python3.5/site-packages
instead of global
/usr/lib/python3.7
Trying to add opencv-python in Thorny through the application fails. In the python program...
import sys
sys.path.append('/home/pi/miniconda3/lib/python3.5/site-packages')
import cv2
results in a
No module named 'cv2.cv2'
I've tried adding it to path also (export PYTHONPATH=/home/pi/miniconda3/lib/python3.5/site-packages:$PYTHONPATH) with no luck.
Because pip is linked to your default Python and I think this default is your miniconda. A better approach is to call the Python version directly with pip. Additionally #Dave W. Smit mentioned that you should better install opencv-python-contrib to use the full OpenCV package (but don´t use both packages!).
$ python-3.7 -m pip install opencv-python-contrib
Or you can use the pip version (if pip is at least version 0.8)
$ pip-3.7 install opencv-python-contrib
Or with pip version 1.5+
$ pip3.7 install opencv-python-contrib
I installed OpenCV for python2 by running:
`sudo apt-get install python-opencv`
But on running
import cv2
I get the following error:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named cv2
My friend did the same and it's working on his machine.
I myself had the same issue, I solved it by first installing pip using the following command
sudo apt-get install python-pip
Then i installed opencv by,
pip install opencv-python
Then i tried importing cv2 in python and it worked like a charm:
import cv2
NOTE: Import must be done inside the python shell
I'm installing mysql using brew on Linux (Ubuntu 14.04)
I type this brew install mysql command I get the following errors
==> Installing mysql dependency: cmake
==> Downloading http://www.cmake.org/files/v3.2/cmake-3.2.2.tar.gz
Already downloaded: /home/sharif/.cache/Homebrew/cmake-3.2.2.tar.gz
==> Downloading https://pypi.python.org/packages/source/S/Sphinx/Sphinx-1.2.3.ta
Already downloaded: /home/sharif/.cache/Homebrew/cmake--sphinx-1.2.3.tar.gz
==> python -c import setuptools... --no-user-cfg install --prefix=/tmp/cmake2015
--record=installed.txt
Traceback (most recent call last):
File "<string>", line 1, in <module>
ImportError: No module named setuptools
READ THIS: https://github.com/Homebrew/linuxbrew/blob/master/share/doc/homebrew/Troubleshooting.md#troubleshooting
These open issues may also help:
cmake builds fail on CLT-only with --env=std (https://github.com/Homebrew/homebrew/issues/29101)
Its is stuck on this tried many a times, don't know what should I do. I'm a naive first time ever installing installing ruby on rails with mysql. I'm following a tutorial which show how to install ruby on rails on MAC I'm copying the same command but got error on this point ..
Please note that I've installed linusbrew, any help would be highly appreciated.
any idea?