I've a problem with importing the PdfPages function from the matplotlib package on my anaconda environment. I get the following error:
Python 2.7.13 |Anaconda 4.4.0 (64-bit)| (default, Dec 20 2016, 23:09:15)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-1)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
Anaconda is brought to you by Continuum Analytics.
Please check out: http://continuum.io/thanks and https://anaconda.org
>>> from matplotlib.backends.backend_pdf import PdfPages
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/hpc/capn/mppi033h/.virtualenv/h5_to_histo_env/lib/python2.7/site-packages/matplotlib/backends/backend_pdf.py", line 32, in <module>
from matplotlib.backend_bases import (RendererBase, GraphicsContextBase,
File "/home/hpc/capn/mppi033h/.virtualenv/h5_to_histo_env/lib/python2.7/site-packages/matplotlib/backend_bases.py", line 63, in <module>
import matplotlib.textpath as textpath
File "/home/hpc/capn/mppi033h/.virtualenv/h5_to_histo_env/lib/python2.7/site-packages/matplotlib/textpath.py", line 17, in <module>
import matplotlib.font_manager as font_manager
File "/home/hpc/capn/mppi033h/.virtualenv/h5_to_histo_env/lib/python2.7/site-packages/matplotlib/font_manager.py", line 1439, in <module>
_rebuild()
File "/home/hpc/capn/mppi033h/.virtualenv/h5_to_histo_env/lib/python2.7/site-packages/matplotlib/font_manager.py", line 1421, in _rebuild
with cbook.Locked(cachedir):
File "/home/hpc/capn/mppi033h/.virtualenv/h5_to_histo_env/lib/python2.7/site-packages/matplotlib/cbook.py", line 2738, in __enter__
files = glob.glob(self.pattern)
AttributeError: 'module' object has no attribute 'glob'
Importing matplotlib (import matplotlib) works fine though. I'm running python in a virtual environment created with Anaconda (/.../.virtualenv/h5_to_histo_env/)
According to conda-V my version is 'conda 4.3.16' and my matplotlib version is 2.0.2 ('np112py27_0').
My Anaconda environment is up to date as well, does anybody know why I get this error?
Update: Reinstalling the virtual anaconda environment and specifying the needed packages at the beginning with the conda create command (and not after the virtual env is already created) fixed it somehow!
Related
I saw someone was answering the same question here: Python for Naoqi (dynamic module not initialized properly), but I follow the answers in the page, still cannot get it working. Could someone advice how to proceed?
Using Python 2.7.10 doesn't help.
Under Anaconda Python 2.7.10:
Python 2.7.10 |Continuum Analytics, Inc.| (default, Oct 19 2015, 18:31:17)
[GCC 4.2.1 (Apple Inc. build 5577)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
Anaconda is brought to you by Continuum Analytics.
Please check out: http://continuum.io/thanks and https://anaconda.org
>>> import naoqi
Traceback (most recent call last):
File "/opt/anaconda3/envs/pepper_test2/lib/python2.7/site.py", line 557, in <module>
main()
File "/opt/anaconda3/envs/pepper_test2/lib/python2.7/site.py", line 539, in main
known_paths = addusersitepackages(known_paths)
File "/opt/anaconda3/envs/pepper_test2/lib/python2.7/site.py", line 275, in addusersitepackages
user_site = getusersitepackages()
File "/opt/anaconda3/envs/pepper_test2/lib/python2.7/site.py", line 250, in getusersitepackages
user_base = getuserbase() # this will also set USER_BASE
File "/opt/anaconda3/envs/pepper_test2/lib/python2.7/site.py", line 240, in getuserbase
USER_BASE = get_config_var('userbase')
File "/opt/anaconda3/envs/pepper_test2/lib/python2.7/sysconfig.py", line 520, in get_config_var
return get_config_vars().get(name)
File "/opt/anaconda3/envs/pepper_test2/lib/python2.7/sysconfig.py", line 453, in get_config_vars
import re
File "/opt/anaconda3/envs/pepper_test2/lib/python2.7/re.py", line 108, in <module>
import _locale
SystemError: dynamic module not initialized properly
Under Mac System Python 2.7.10:
Python 2.7.10 (default, Oct 6 2017, 22:29:07)
[GCC 4.2.1 Compatible Apple LLVM 9.0.0 (clang-900.0.31)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import naoqi
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/cchan/Documents/technical/python_sdk/pynaoqi-python2.7-2.5.5.5-mac64/lib/python2.7/site-packages/naoqi.py", line 9, in <module>
import qi
File "/Users/cchan/Documents/technical/python_sdk/pynaoqi-python2.7-2.5.5.5-mac64/lib/python2.7/site-packages/qi/__init__.py", line 88, in <module>
from _qi import Application as _Application
ImportError: dlopen(/Users/cchan/Documents/technical/python_sdk/pynaoqi-python2.7-2.5.5.5-mac64/lib/python2.7/site-packages/_qi.so, 2): Library not loaded: /Library/Frameworks/Python.framework/Versions/2.7/Python
Referenced from: /Users/cchan/Documents/technical/python_sdk/pynaoqi-python2.7-2.5.5.5-mac64/lib/python2.7/site-packages/_qi.so
Reason: image not found
I have also added the PYTHONPATH in my ~/.bash_profile:
export PYTHONPATH="$PYTHONPATH:/Users/cchan/Documents/technical/python_sdk/pynaoqi-python2.7-2.5.5.5-mac64/lib/python2.7/site-packages"
export DYLD_LIBRARY_PATH="$DYLD_LIBRARY_PATH:/Users/cchan/Documents/technical/python_sdk/pynaoqi-python2.7-2.5.5.5-mac64/lib"
export DYLD_FRAMEWORK_PATH="$DYLD_FRAMEWORK_PATH:/Users/cchan/Documents/technical/python_sdk/pynaoqi-python2.7-2.5.5.5-mac64"
Could someone advise what to do? Thanks in advance!
I found out the problem. The system Python 2.7.10 came with the Mac OS X doesn't work. I have to download the Python 2.7.10 from the Python website and install that in order to have it work: Python Release Website
This answer was original posted by Calvin in question see revision 2
I am completely new to Python but I enjoyed it very much. I start with Python 2.7 before migrating to Python 3 since many applications for work have to do with Python 2.7.
I have quite sadly many version of python2.7 on my MacBook. One from Apple, one from Homebrew, one from Anaconda. I have pip version 18.0 installed.
I wanted to install many modules (scipy in particular) and I ran into the following problem.
On the console:
Python 2.7.15 (v2.7.15:ca079a3ea3, Apr 29 2018, 20:59:26)
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.57)] on darwin
Type "copyright", "credits" or "license()" for more information.
>>> import matplotlib
I get the error message:
Traceback (most recent call last):
File "", line 1, in
import matplotlib
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/init.py", line 130, in
from matplotlib.rcsetup import defaultParams, validate_backend, cycler
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/rcsetup.py", line 29, in
from matplotlib.fontconfig_pattern import parse_fontconfig_pattern
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/fontconfig_pattern.py", line 28, in
from backports.functools_lru_cache import lru_cache
ImportError: No module named functools_lru_cache
I looked on the web and found the solution for that by typing:
pip install --user matplotlib
Now when I do:
>>> import matplotlib
I get the message:
Traceback (most recent call last):
File "", line 1, in
import matplotlib
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/init.py", line 126, in
from . import cbook
ImportError: cannot import name cbook
There is a confusion on the web about how to solve this problem. Is there still hope I can get back running?
I have installed installed the following modules in my EC2 server which already has python (3.6) & anaconda installed :
snappy
pyarrow
s3fs
fastparquet
except fastparquet everything else works on importing. When I try to import fastparquet it throws the following error :
[username#ip8 ~]$ conda -V
conda 4.2.13
[username#ip-~]$ python
Python 3.6.0 |Anaconda custom (64-bit)| (default, Dec 23 2016, 12:22:00)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-1)] on linux
Type "help", "copyright", "credits" or "license" for more information.
import fastparquet
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/username/anaconda3/lib/python3.6/site-packages/fastparquet/__init__.py", line 15, in <module>
from .core import read_thrift
File "/home/username/anaconda3/lib/python3.6/site-packages/fastparquet/core.py", line 11, in <module>
from .compression import decompress_data
File "/home/username/anaconda3/lib/python3.6/site-packages/fastparquet/compression.py", line 43, in <module>
compressions['SNAPPY'] = snappy.compress
AttributeError: module 'snappy' has no attribute 'compress'
How do I go about fixing this ?
Unfortunately, there are multiple things in python-land called "snappy". I believe you may have the wrong one, in which case one of the following conda commands should solve this for you:
conda install python-snappy
or
conda install python-snappy -c conda-forge
where the latter is slightly more recent (releases the GIL which can be important in threaded applications).
I have recently upgraded the system to 16.04 Gnome. The most troubling thing that I am facing is that I cannot import a NAOqi library for my work. The python version of this library was pretty simple to set-up. One just has to untar the file and then enter a path variable called PYTHONPATH pointing to this library and it worked like a charm in 14.04. Now since upgrade I am facing:
Python 2.7.12 (default, Jul 1 2016, 15:12:24)
[GCC 5.4.0 20160609] on linux2
Type "help", "copyright", "credits" or "license" for more information.
import naoqi
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/dell/nao_sdk/pynaoqi/naoqi.py", line 7, in <module>
import qi
File "/home/dell/nao_sdk/pynaoqi/qi/__init__.py", line 72, in <module>
from _qi import Application as _Application
ImportError: libqipython.so: cannot open shared object file: No such file or directory
If I add a path variable:
export LD_LIBRARY_PATH=:/home/dell/nao_sdk/pynaoqi/
The error changes to:
Python 2.7.12 (default, Jul 1 2016, 15:12:24)
[GCC 5.4.0 20160609] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import naoqi
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/dell/nao_sdk/pynaoqi/naoqi.py", line 7, in <module>
import qi
File "/home/dell/nao_sdk/pynaoqi/qi/__init__.py", line 72, in <module>
from _qi import Application as _Application
ImportError: libboost_regex.so.1.55.0: cannot open shared object file: No such file or directory
Please help me what should I do to get it working? I have also used python 2.6.9 but same error occurs with error below.
ImportError: libboost_python.so.1.55.0: cannot open shared object file: No such file or directory
Installing libboost1.55 did the trick. 16.04 comes with libboost1.58 but naoqi is not yet compatible with it. Manual installation of libboost1.55 solved the import error.
I am trying to use the pydna module on a machine running Ubuntu 14.04, and am getting the following error when I try to import it:
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.7/dist-packages/pydna/__init__.py", line 97, in <module>
from pydna.amplify import Anneal
File "/usr/local/lib/python2.7/dist-packages/pydna/amplify.py", line 32, in <module>
from pydna.dsdna import rc
File "/usr/local/lib/python2.7/dist-packages/pydna/dsdna.py", line 63, in <module>
from IPython.display import Markdown as display
ImportError: cannot import name Markdown
Has anyone found a way to resolve this? I have tried reinstalling IPython, and pydna. The offending chunk in dsdna.py is the following:
(lines 58-63)
try:
import IPython
except ImportError:
def display(item): return item
else:
from IPython.display import Markdown as display
Any help would be greatly appreciated!
(Python 2.7.6)
I have the IPython 4.1.1 installed and it works for me (see below). Which version do you have? Also, which pydna version did you install?
This could be due to a too old version of IPython, recently IPython was split into IPython and Jupyter which caused some code to break.
(bjorn)bjorn#bjorn-ThinkPad-T450s:~/Desktop/GMB$ python
Python 2.7.10 |Anaconda 2.5.0 (64-bit)| (default, Oct 19 2015, 18:04:42)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-1)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
Anaconda is brought to you by Continuum Analytics.
Please check out: http://continuum.io/thanks and https://anaconda.org
>>> from IPython.display import Markdown as display
>>> import IPython
>>> IPython.__version__
'4.1.1'