pyexiv2 with homebrew python 2.7.4 - python

I have just installed python (2.7.4) with brew on my macbook pro (10.7.5).
I also installed exiv2 and pyexiv2 with brew.
When I import pyexiv2 from the python interpreter, I got the following error :
Fatal Python error: Interpreter not initialized (version mismatch?)
What I should do to correct that (considering that I do not want to remove the brewed python as suggested in this thread:
How to install python library Pyexiv2 and Gexiv2 on osx 10.6.8?)
Thanks a lot for any advice !

After much searching and looking at a few complicated solutions across the web, I found a simple method to solve this problem, in the Homebrew wiki itself!
The root of the problem is the boost dependency library, which by default links to the system python and not a brewed python, from the wiki:
Note that e.g. the boost bottle is built against system python and should be brewed from source to make it work with a brewed Python. This can even happen when both python executables are the same version (e.g. 2.7.2). The explanation is that Python packages with C-extensions (those that have .so files) are compiled against a certain python binary/library that may have been built with a different arch (e.g. Apple's python is still not a pure 64bit). Other things can go wrong, too. Welcome to the dirty underworld of C.
(emphasis mine)
So first uninstall the dependency libraries and pyexiv2 itself with:
brew rm $(brew deps pyexiv2)
brew rm pyexiv2
Then install boost from source as indicated here:
brew install boost --build-from-source
Note: building boost might take time, so be patient, it took my system 27.9 mins! (output below)
usr/local/Cellar/boost/1.54.0: 9865 files, 568M, built in 27.9 minutes
Then reinstall pyexiv2 and dependencies:
brew install pyexiv2
That's it, now importing pyexiv2 should work flawlessly.

Check which Python you are running (which python), and run python with the -v option to see where it is looking for modules. Check that all those things match your expectations. Then run brew doctor, and if that doesn't complain about anything, report a bug.

I had a bunch of trouble installing pyexiv2 with Homebrew on macOS Sierra using bool.dev's answer above. The Homebrewed pyexiv2 kept throwing a Segmentation Fault 11 on import.
I eventually got it installed and working with the Homebrewed Python by modifying bool.dev's answer with the following commands:
brew install boost --build-from-source
brew install boost-python
brew install exiv2
sudo pip install git+https://github.com/escaped/pyexiv2.git
I found the last line in the following document on Page 30 after getting sucked down a Google hole.
Hope this helps!

Related

How do I install python third party libs on the m1 chip?

The Mac Book Air M1 chip doesn't seem to support pep517 according to the errors of installing third-party libraries with pip or brew. Even using these methods without pep517 downloading the library locally didn't work. How does one circumvent this?
Error from using pip install pandas:
Failed to build numpy
ERROR: Could not build wheels for numpy which use PEP 517 and cannot be installed directly
I've tried this:
pip install <lib>
installing the library locally and trying to install with pip without pep517
brew install <lib>
openblas installation of lib
python env on the intel venv
I had the exact same problem, with a different library but with the same error code for PEP 517, I was using python 3.9 at the time, I checked the docs and found out that it's a problem with the python version for the library, downgraded to Python 3.6 and voila! it worked.
Basically try downgrading to Python 3.6 and check.
Installing python libraries through Anaconda seems to work. I simply downloaded the installer and could later use the libraries globally. If someone has a better in-depth explanation, feel free to comment.
I was having the same message when trying to install a different package. I solved by removing the CommandLineTools and installing it again. The steps were:
sudo rm -r /Library/Developer/CommandLineTools
wait for command prompt...
xcode-select --install
This solved the issue for me.

FFmpeg installation requiring python uninstallation on Mac

Did brew install ffmpeg, installs some packages and gives this error :
Error: python is already installed from !
Please brew uninstall python first."
I have python3.6.5 installed via brew, for using Tensorflow etc. No other python version is installed via brew right now. Why is this error coming up? What version does FFmpeg need?
Earlier I actually uninstalled python and that broke my system in many frustrating ways. I had to delete everything and start over. What is a safer way to get this working?

How to install module and package in python

I'm trying to start with OpenCV with python. I have experience c# and I have knowledge of c++. However, I feel more comfortable with python instead of c++. I installed OpenCV then python 3.4 in visual studio 2015. At the beginning I've received an error numpy, "Module couldn't be found", thankfully, I resolved it. The I got another error cv2 "Module couldn't be found" I asked an question yesterday, but I think the question has been left away. Anyways, I'm not complaining, but I still need some help please to stat with OpenCV in python.
Installing python 3.4 Successful
Installing numpy Successful
installing matpilotlib Failed
installing cv2 Failed
can anybody help me please thanks a lot.
It's very common to install Python packages through pip today (recursive acronym for pip installs packages). However, this is not that trivial under Windows.
How to install matplotlib:
Try to open a commandline and type in pip install matplotlib. If this does not work, you'll need to do some more work to get pip running. I gave a detailed answere here: Not sure how to fix this Cmd command error?.
How to install OpenCV:
The Python OpenCV DLL must be made for your version of Python and your system architecture (or, to be more specific, the architecture your Python was compiled for).
Download OpenCV for your Python version (2/3)
Try replacing the x64 version with the x86 version
There are a lot of different binaries here: http://www.lfd.uci.edu/~gohlke/pythonlibs/#opencv. Try to get the one exactly matching your Python version and System architecture and install it via pip (cp35 means CPython version 3.5 ect.).
If you have the OpenCV .whl file matching your system configuration, do pip install file.whl.
Hope this helps!
You can install matplotlib using pip (which is already installed on your machine - mentioned in your previous quesiton):
pip install matplotlib
more info:
http://matplotlib.org/faq/installing_faq.html
You may be better off using an package such as pythonxy as a start, e.g. from https://python-xy.github.io/ , instead of installing each single package manually.

mac following brew install python warning thrown unstable state

Pundits warn against installing python in a mac usr/bin/Frameworks area.
Python self-installers write to Framework by default.
pundits advise using brew install of python to avoid the above.
Brew install python however, results in unstable state
Idle reports tclsh mismatch.
Pundits advise active state installer of correct tclsh. These are high-level python cognoscenti, and real pundits, lilies amidst the thorns.
Active-state installs to Frameworks (can you imagine?).
The said installer allows no other installation directory.
Brew installed python fails to see the active-state tclsh.
However, if one of you admonitory pundits could help me with a logical, non-idiomatic description of a process that will associate the appropriate "tclsh" in usr/bin with python3 in usr/local/bin, I would be ecstatic.
Homebrew's Python build will only attempt to recognize brewed or system Tcl/Tk. To build against Homebrew's Tcl/Tk (and install it first if necessary), install Python with brew install python3 --with-tcl-tk.

brew install boost does not give correct directory structure, no python tutorial

I installed boost on my Macbook Pro laptop using brew install boost and it proceeded without errors.
$ brew install boost
==> Downloading https://downloads.sf.net/project/machomebrew/Bottles/boost/1.56.0.mavericks.bottle.tar.gz
######################################################################## 100.0%
==> Pouring boost-1.56.0.mavericks.bottle.tar.gz
/usr/local/Cellar/boost/1.56.0: 10471 files, 438M
However, when I check my directory structure:
ls /usr/local/Cellar/boost/1.56.0/
INSTALL_RECEIPT.json include/ lib/
It does not match the directory structure for boost as shown on the official documentation. In particular, I can't find the files needed to build boost.python and the files related to the tutorial. Has anyone else run into this problem, and if so, how can I find the libs/python/example/quickstart/ directory?
First, you need to install Boost with Python support. A vanilla brew install boost won't do this for you. If you have the, as of right now, latest version of Homebrew (0.9.5), you can do:
brew install boost-python
Otherwise, you should use:
brew install boost --with-python
Second, the directory structure you linked is for the 1.41.0 Windows version of the Boost distribution. If you're installing the latest Boost distribution on a Unix system like OS X, you should be looking at this.
Finally, there is no libs/python/example/quickstart when you install Boost with Brew. Everything you need to use Boost.Python is in the library binaries that are installed on your system when you use brew install boost-python. When you install Boost using Homebrew, you aren't getting the source code ultimately. Homebrew builds the libraries for you, so there's no need to "build Boost.Python".

Categories

Resources