Install libtiff on Mavericks - python

I made a Python script that needs a libtiff module to run. Do you have any suggestions on how to install libtiff? I tried to do it using fink, but I got the following error:
Failed: no package found for specification libtiff!
I also installed libtiff using brew, and in this case I get
ImportError: No module named libtiff

Homebrew worked fine for me. Have you installed the Python bindings for libtiff? For example, ...
% brew install libtiff
==> Downloading https://downloads.sf.net/project/machomebrew/Bottles/libtiff-4.0.3.mavericks.bottle.tar.gz
######################################################################## 100.0%
==> Pouring libtiff-4.0.3.mavericks.bottle.tar.gz
/usr/local/Cellar/libtiff/4.0.3: 254 files, 3.8M
% brew install python
% pip install --upgrade setuptools
% pip install --upgrade pip
% pip install numpy
% pip install -e svn+http://pylibtiff.googlecode.com/svn/trunk/
% python
Python 2.7.6 (default, Mar 12 2014, 18:28:55)
[GCC 4.2.1 Compatible Apple LLVM 5.1 (clang-503.0.38)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import libtiff
>>> libtiff
<module 'libtiff' from '/Users/me/src/svn/libtiff/__init__.pyc'>
>>>

Related

Installing python package jieba3k changes version of already installed package jieba

Here's how to reproduce my issue:
Create a new virtualenv:
$ virtualenv testenv --python=/usr/bin/python3.6
Running virtualenv with interpreter /usr/bin/python3.6
Using base prefix '/usr'
New python executable in testenv/bin/python3.6
Also creating executable in testenv/bin/python
Installing setuptools, pip, wheel...done.
$ source testenv/bin/activate
(testenv) $ cd test
Install jieba and check __version__:
(testenv) test$ pip3 install jieba
Collecting jieba
Installing collected packages: jieba
Successfully installed jieba-0.39
(testenv) test$ python
Python 3.6.5 (default, Mar 29 2018, 03:28:50)
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import jieba
>>> jieba.__version__
'0.39'
>>> Quit (core dumped)
Ok, version 0.39.
Install jieba3k:
(testenv) test$ pip3 install jieba3k
Collecting jieba3k
Installing collected packages: jieba3k
Successfully installed jieba3k-0.35.1
Recheck jieba __version__:
(testenv) test$ python
Python 3.6.5 (default, Mar 29 2018, 03:28:50)
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import jieba
>>> jieba.__version__
'0.34'
>>> Quit (core dumped)
New version is 0.34.
Why is this happening? And how can I avoid this?
jieba and jieba3k aren't two different packages, they are two different versions of the same package with jieba being newer. When you install jieba3k it overrides package jieba with older version.
In short: forget about jieba3k, use only jieba.

python package installed but could not import

I have tried to re-install and got the following message:
Requirement already satisfied: troposphere==1.8.2 in /usr/local/lib/python2.7/site-packages (from -r requirements.txt (line 13)
I checked my python version and I could see this as same:
animjain$ python -V
Python 2.7.10
When I try to import a module, get the following error:
animjain$ python
Python 2.7.10 (default, Oct 23 2015, 19:19:21)
[GCC 4.2.1 Compatible Apple LLVM 7.0.0 (clang-700.0.59.5)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from troposphere import Join, Ref, FindInMap
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named troposphere
You should use virtualenv to install dependencies for your project. You don't need to clog global site-packages.
For example:
sudo apt-get install virtualenv
cd ~
virtualenv your_test_venv
source your_test_venv/bin/activate
pip install troposphere
After that you can use your new package.
When you want to deactivate your virtualenv you can run command deactivate
In case you have multiple Python versions on your machine, install with the same Python command, so instead of:
animjain$ pip install troposphere==1.8.2
run:
animjain$ python -mpip install troposphere==1.8.2

Python3, lxml and "Symbol not found: _lzma_auto_decoder" on Mac OS X 10.9

I have installed python 3 using homebrew and afterwards installed pip3 and lxml.
The following line
from lxml import entree
leads to the following error:
$ python3
Python 3.3.5 (v3.3.5:62cf4e77f785, Mar 9 2014, 01:12:57)
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from lxml import etree
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/site- packages/lxml/etree.so, 2): Symbol not found: _lzma_auto_decoder
Referenced from: /Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/site-packages/lxml/etree.so
Expected in: flat namespace
in /Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/site-packages/lxml/etree.so
>>> exit();
Does anybody know how to fix this?
I have deleted all versions of python from
/Library/Frameworks/Python.framework/Versions/
afterwards I have reinstalled python 3 using brew and recreated the symlinks using
brew link --overwrite python3
Deleting lxml and re-installing lxml a SECOND time worked for me (weird, not happy with this solution):
pip3.4 uninstall lxml
pip3.4 install lxml
pip3 complains about lxml being already installed, remove manually the install files with a command like:
rm -fr /private/var/folders/dj/saljfdsf12_sd7s89dfg9080000rb/T/pip_build_user/lxml
Then again:
pip3.4 install lxml
And it worked. I couldn't reproduce the original error message to find root cause of this problem.
If you use Homebrew and have xz installed, the following should work:
STATIC_DEPS=true CFLAGS=-I/usr/local/include/lzma pip install -U lxml
Otherwise set CFLAGS to the place where your lzma headers are located.
I had this same issue,
What I did:
First, I ensured I did not have the ports py27-xml2, py27-xslt or py27-lxml installed
sudo port installed | grep py27
I installed port py27-pip and checked that $PATH variable pointed it. Also installed py27-setuptools.
$ sudo port contents py27-pip | grep /pip$
/opt/local/Library/Frameworks/Python.framework/Versions/2.7/bin/pip
in ~/.bash_profile:
export PATH="/opt/local/Library/Frameworks/Python.framework/Versions/2.7/bin:${PATH}"
$ which pip
/opt/local/Library/Frameworks/Python.framework/Versions/2.7/bin/pip
Then I installed lxml with easy_install which was located in the same directory than pip
STATIC_DEPS=true sudo easy_install-2.7 lxml
The building process was displaying:
$ STATIC_DEPS=true sudo easy_install-2.7 lxml
Searching for lxml
Reading https://pypi.python.org/simple/lxml/
Downloading
....
Building without Cython.
Using build configuration of libxslt 1.1.29
Building against libxml2/libxslt in the following directory: /Applications/MAMP/Library/
....
libxml/xmlversion.h: No such file or directory
I moved MAMP (seems to already come with those libs) at the end of $PATH, uninstalled lxml (displayed "Symbol not found: _lzma_auto_decoder" error) and repeated last command:
$ STATIC_DEPS=true sudo easy_install-2.7 -m "lxml==3.6.4"
in ~/.bash_profile:
export PATH="/opt/local/Library/Frameworks/Python.framework/Versions/2.7/bin:${PATH}:/Applications/MAMP/Library/bin:/Applications/MAMP/Library"
$ source ~/.bash_profile
$ STATIC_DEPS=true sudo easy_install-2.7 lxml
This fixed the error either inside or outside virtualenv
$ python
Python 2.7.12 (default, Jun 29 2016, 12:46:54)
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.57)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from lxml import etree
>>>

Upgrading devel version of statsmodels

I've got statsmodels 0.5.0 and I want to upgrade to the latest version which is 0.6.0.
So I do
$ git clone git://github.com/statsmodels/statsmodels.git
$ cd statsmodels
$ pip install .
But, I get an error:
error: can't copy 'statsmodels/nonparametric/_smoothers_lowess.c': doesn't exist or not a regular file
Apparently the solution is to install Cython (which I thought was already installed, or how could statsmodels 0.5.0 ever have worked in the first place..?!?).
Anyway, so it becomes:
$ git clone git://github.com/statsmodels/statsmodels.git
$ cd statsmodels
$ pip install cython
$ pip install .
$ python
Python 2.7.3 |CUSTOM| (default, Apr 11 2012, 17:52:16)
[GCC 4.1.2 20080704 (Red Hat 4.1.2-44)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import statsmodels
>>> statsmodels.version.full_version
'0.6.0.dev-b472807'

How to install a module for python 2.6 on CentOS?

After I install python 2.6 on CentOS by:
wget http://download.fedoraproject.org/pub/epel/5/i386/epel-release-5-4.noarch.rpm
sudo rpm -ivh epel-release-5-4.noarch.rpm
yum install python26
Then I install pyPdf by:
yum install pyPdf
However, the pyPdf is only available to the old python 2.4:
# python
Python 2.4.3 (#1, Jan 9 2013, 06:49:54)
[GCC 4.1.2 20080704 (Red Hat 4.1.2-54)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import pyPdf
>>> import sys
>>> print sys.path
['', '/usr/lib/python24.zip', '/usr/lib/python2.4', '/usr/lib/python2.4/plat-linux2', '/usr/lib/python2.4/lib-tk', '/usr/lib/python2.4/lib-dynload', '/usr/lib/python2.4/site-packages', '/usr/lib/python2.4/site-packages/Numeric', '/usr/lib/python2.4/site-packages/gtk-2.0']
it's not available to the newly install python 2.6:
# python26
Python 2.6.8 (unknown, Nov 7 2012, 14:47:34)
[GCC 4.1.2 20080704 (Red Hat 4.1.2-52)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> print sys.path
['', '/usr/lib/python26.zip', '/usr/lib/python2.6', '/usr/lib/python2.6/plat-linux2', '/usr/lib/python2.6/lib-tk', '/usr/lib/python2.6/lib-old', '/usr/lib/python2.6/lib-dynload', '/usr/lib/python2.6/site-packages']
>>> import pyPdf
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named pyPdf
How can I install pyPdf for python 2.6?
How about creating a virtualenv and install pyPdf with pip
$ curl -O https://pypi.python.org/packages/source/v/virtualenv/virtualenv-X.X.tar.gz
$ tar xvfz virtualenv-X.X.tar.gz
$ cd virtualenv-X.X
$ python26 virtualenv.py myVirtualenv
$ source myVirtualenv/bin/activate
$ pip install pyPdf
Read more about virtualenv here
Not sure how you're doing it. I have recently installed pyPdf on CentOS for Python 2.7. A simple yum worked for me.
yum install pyPdf
pyPdf is also available for newer versions. Check here
Edit:
May be having two different versions of Python is causing this issue
for you. CentOS comes with default installation of v2.4. Remove all
the previous versions and install again.
For CentOS version lower than 6, python 2.4 comes by default. For version 6 and above its python2.6 .
Now I would strictly advise not to upgrade the base Python installation i.e python2.4 in the earlier versions, as that would break lot of system level funcationalities that expect default python to be 2.4.
Your question can be solved in multiple ways :
yum install always does an installation for default python. If its 2.4 it will install the package for 2.4.
To install package for 2.6, download easy_install for 2.6 or PIP for 2.6 and then simply do easy_install {{package_name}} or pip install {{package_name}}
To keep your environments different, as suggested by #Dikei install a virtual-env and then install your packages. This is method is one of the best practices for maintaining multiple python environments.
Quick installation of Python !!!
Get the latest verion of Python 2.6.9
wget https://www.python.org/ftp/python/2.6.9/Python-2.6.9.tar.xz
Extract thae package
tar xf Python-2.6.9.tar.xz
Configure them
cd Python-2.6.9
./configure --prefix=/usr/local --enable-unicode=ucs4 --enable-shared LDFLAGS="-Wl,-rpath /usr/local/lib"
Install them
make && make altinstall
Check Version:
python --version
Python 2.6.9
Credits:https://danieleriksson.net
Hope this helps !!!

Categories