Runtime error with kombu on Mac OS 10.9.5 - python

I get a strange error when trying to use Celery from python on OS X 10.9.5. This used to work, but it's now (apparently) failing to use some C library when importing kombu.five.
~$ python
Python 2.7.8 (default, Aug 24 2014, 21:26:19)
[GCC 4.2.1 Compatible Apple LLVM 5.1 (clang-503.0.40)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import celery
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.7/site-packages/celery/__init__.py", line 130, in <module>
from celery import five
File "/usr/local/lib/python2.7/site-packages/celery/five.py", line 51, in <module>
from kombu.five import monotonic
File "/usr/local/lib/python2.7/site-packages/kombu/five.py", line 52, in <module>
absolute_to_nanoseconds = CoreServices.AbsoluteToNanoseconds
File "/usr/local/Cellar/python/2.7.8_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ctypes/__init__.py", line 378, in __getattr__
func = self.__getitem__(name)
File "/usr/local/Cellar/python/2.7.8_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ctypes/__init__.py", line 383, in __getitem__
func = self._FuncPtr((name_or_ordinal, self))
AttributeError: dlsym(RTLD_DEFAULT, AbsoluteToNanoseconds): symbol not found
I am using python 2.7.8 (installed via brew install python) and the latest versions of celery and kombu (installed via pip install celery). Any hint?
Here is my output of brew --config:
HOMEBREW_VERSION: 0.9.5
ORIGIN: https://github.com/Homebrew/homebrew.git
HEAD: c32db7bdaaedbf94d070ac13c1f8c42bd79c3853
Last commit: 51 minutes ago
HOMEBREW_PREFIX: /usr/local
HOMEBREW_CELLAR: /usr/local/Cellar
CPU: quad-core 64-bit sandybridge
OS X: 10.9.5-x86_64
Xcode: 6.0.1
CLT: 6.0.0.0.1.1410400753
Clang: 6.0 build 600
X11: 2.7.6 => /opt/X11
System Ruby: 2.0.0-481
Perl: /usr/bin/perl
Python: /usr/local/bin/python => /usr/local/Cellar/python/2.7.8_1/Frameworks/Python.framework/Versions/2.7/bin/python2.7
Here is some more output regarding ctypes:
>>> import ctypes, ctypes.util
>>> CoreServices = ctypes.CDLL(ctypes.util.find_library('CoreServices'))
>>> print CoreServices
<CDLL 'None', handle fffffffffffffffe at 10eac1e50>
>>> print CoreServices.AbsoluteToNanoseconds
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/Cellar/python/2.7.8_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ctypes/__init__.py", line 378, in __getattr__
func = self.__getitem__(name)
File "/usr/local/Cellar/python/2.7.8_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ctypes/__init__.py", line 383, in __getitem__
func = self._FuncPtr((name_or_ordinal, self))
AttributeError: dlsym(RTLD_DEFAULT, AbsoluteToNanoseconds): symbol not found

Found it, thanks TimSmith! It was a conflict in the DYLD_FALLBACK_LIBRARY_PATH environment variable between the libraries used by Homebrew Python and Paraview.

Related

Msys2 with python 3.8: ImportError: cannot import name 'open_code' from 'io'

NOTE: There have been several EDITs to the question, as per comments. They are indicated below, and separated by lines.
As of now, the only remaining issue seems to be that numpy cannot load, possibly (but not certainly) due to two alternative python 3.8 systems present.
I have updated my msys2 system a couple of months ago.
That apparently included an update from python 3.7 to 3.8, but which left me with two broken pythons: I can start python when it is 3.7, but there are no associated packages, and I cannot start python when it is 3.8, which is the version holding packages.
I do not know what went wrong with that, or what did I do wrong.
I just noticed this now with the first time I mean to use python again after the upgrade.
I will describe here a sequence of steps I followed and what I found.
I will post supporting code below for clarity.
I can start python, but pandas (e.g.) and many other packages are not found in python.
Checking further, /mingw64/lib/python3.7/site-packages is essentially empty (surely emptied when upgrading to 3.8).
Looking for the pandas package, I found I have one version installed.
The pandas version is for python 3.8, surely upgraded from 3.7.
I redirected PYTHONPATH from 3.7 to 3.8
Now I cannot even start python.
EDIT Now I can start python, with some misconfiguration issues (i.e., partially fixed).
Now the question is
How can I fix python3.8, which gives the error below?
ImportError: cannot import name 'open_code' from 'io' (unknown location)
How can I fix python3.8, which gives the problems below?
New problems:
5.1. I should have python pointing to 3.8, and also fix packages.
5.2. Some modules are not found, some other are.
Note: I don't know if Msys2 upgrade breaks python2-pyqt5 has anything to do with this.
Related:
https://github.com/tox-dev/tox/issues/1334
https://github.com/yan12125/python3-android/issues/19
https://python-forum.io/Thread-Fatal-Python-error-init-sys-streams-can-t-initialize-sys-standard-streams-Attribute
TL;DR: Supporting code
pandas not found
$ python
Python 3.7.4 (default, Jul 11 2019, 10:29:54)
[GCC 9.1.0] on msys
Type "help", "copyright", "credits" or "license" for more information.
Reading /home/user1/.pythonrc
readline is in /usr/lib/python3.7/lib-dynload/readline.cpython-37m.dll
>>> import pandas
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'pandas'
>>>
pandas is actually installed
$ pacman -Sl | grep python | grep installed
mingw64 mingw-w64-x86_64-python 3.8.2-1 [installed: 3.8.1-1]
mingw64 mingw-w64-x86_64-python-apipkg 1.5-1 [installed]
...
mingw64 mingw-w64-x86_64-python-pandas 1.0.3-1 [installed: 1.0.1-1]
...
mingw64 mingw-w64-x86_64-python2-setuptools 44.1.0-1 [installed: 42.0.2-1]
msys python 3.7.4-1 [installed]
msys python2 2.7.17-1 [installed]
My pandas version is for python 3.8
$ pacman -Ql mingw-w64-x86_64-python-pandas | head -5
mingw-w64-x86_64-python-pandas /mingw64/
mingw-w64-x86_64-python-pandas /mingw64/lib/
mingw-w64-x86_64-python-pandas /mingw64/lib/python3.8/
mingw-w64-x86_64-python-pandas /mingw64/lib/python3.8/site-packages/
mingw-w64-x86_64-python-pandas /mingw64/lib/python3.8/site-packages/pandas-1.0.1-py3.8.egg-info/
I redirected PYTHONPATH from 3.7 to 3.8
Changed
export PYVERSION="3.7"
export PYTHONDIR2="${MINGW_HOME}/lib/python${PYVERSION}"
export PYTHONPATH="${PYTHONDIR2}:${PYTHONDIR2}/site-packages"
to
export PYVERSION="3.8"
...
Now I cannot even start python.
EDIT: Old problem:
$ python
Fatal Python error: init_sys_streams: can't initialize sys standard streams
Traceback (most recent call last):
File "/c/Users/user1/Documents/appls_mydocs/PortableApps/MSYS2Portable/App/msys32/mingw64/lib/python3.8/io.py", line 54, in <module>
ImportError: cannot import name 'open_code' from 'io' (unknown location)
Aborted (core dumped)
New problems:
$ python --version
Python 3.7.4
$ type python
python is hashed (/usr/bin/python)
$ ls /usr/bin/python
/usr/bin/python
$ python3.8
Python 3.8.2 (default, Apr 9 2020, 13:17:39) [GCC 9.3.0 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
Reading C:/Users/user1/Documents/appls_mydocs/PortableApps/MSYS2Portable/App/msys32/home/user1/.pythonrc
Module readline not available.
Traceback (most recent call last):
File "C:/Users/user1/Documents/appls_mydocs/PortableApps/MSYS2Portable/App/msys32/home/user1/.pythonrc", line 42, in <module>
del os, atexit, readline, rlcompleter, save_history, historyPath
NameError: name 'readline' is not defined
>>> import readline
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'readline'
>>> import zipfile
>>> import pandas
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:/Users/user1/Documents/appls_mydocs/PortableApps/MSYS2Portable/App/msys32/mingw64/lib/python3.8/site-packages/pandas/__init__.py", line 16, in <module>
raise ImportError(
ImportError: Unable to import required dependencies:
numpy: DLL load failed while importing _ctypes: No se puede encontrar el módulo especificado.
>>> import numpy
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:/Users/user1/Documents/appls_mydocs/PortableApps/MSYS2Portable/App/msys32/mingw64/lib/python3.8/site-packages/numpy/__init__.py", line 142, in <module>
from . import core
File "C:/Users/user1/Documents/appls_mydocs/PortableApps/MSYS2Portable/App/msys32/mingw64/lib/python3.8/site-packages/numpy/core/__init__.py", line 106, in <module>
from . import _dtype_ctypes
File "C:/Users/user1/Documents/appls_mydocs/PortableApps/MSYS2Portable/App/msys32/mingw64/lib/python3.8/site-packages/numpy/core/_dtype_ctypes.py", line 25, in <module>
import _ctypes
ImportError: DLL load failed while importing _ctypes: No se puede encontrar el módulo especificado.
>>> exit()
Error in atexit._run_exitfuncs:
Traceback (most recent call last):
File "<frozen importlib._bootstrap>", line 991, in _find_and_load
File "<frozen importlib._bootstrap>", line 973, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'readline'
EDIT #2: Adding info as requested.
I just noticed I don't have pip. That matches the fact that I never installed any package with pip...
$ echo $PATH
/usr/local/bin:/usr/bin:/bin:/opt/bin:/c/Windows/System32:/c/Windows:/c/Windows/System32/Wbem:/c/Windows/System32/WindowsPowerShell/v1.0/:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl:/c/Users/user1/OneDrive/Documents/soft-hard-ware/linux-ubuntu:/c/Users/user1/OneDrive/Documents/soft-hard-ware/linux-ubuntu/rsync:/c/Users/user1/Documents/appls_mydocs/science-math-visualization/gp524-win64-mingw_3/gnuplot/bin:/mingw64/bin
$ echo $PYTHONPATH
/c/Users/user1/Documents/appls_mydocs/PortableApps/MSYS2Portable/App/msys32/mingw64/lib/python3.8:/c/Users/user1/Documents/appls_mydocs/PortableApps/MSYS2Portable/App/msys32/mingw64/lib/python3.8/site-packages
$ echo $PYTHONSTARTUP
/home/user1/.pythonrc
$ which python3.8
/mingw64/bin/python3.8
$ python3.8 -m pip freeze
C:/Users/user1/Documents/appls_mydocs/PortableApps/MSYS2Portable/App/msys32/mingw64/bin/python3.8.exe: No module named pip
$ python3.8 -c "import sys; print(sys.builtin_module_names)"
('_abc', '_ast', '_codecs', '_collections', '_functools', '_imp', '_io', '_locale', '_operator', '_signal', '_sre', '_stat', '_string', '_symtable', '_thread', '_tracemalloc', '_warnings', '_weakref', '_winapi', 'atexit', 'builtins', 'errno', 'faulthandler', 'gc', 'itertools', 'marshal', 'msvcrt', 'nt', 'sys', 'time', 'winreg', 'xxsubtype')
EDIT #3:
Posting as requested, plus additional info.
$ cat .pythonrc
import os
print( "Reading " + os.path.realpath(__file__) )
# enable syntax completion
try:
import readline
print( "readline is in " + readline.__file__ )
except ImportError:
print("Module readline not available.")
else:
import rlcompleter
readline.parse_and_bind("tab: complete")
# From https://docs.python.org/2/tutorial/interactive.html
# Add auto-completion and a stored history file of commands to your Python
# interactive interpreter. Requires Python 2.0+, readline. Autocomplete is
# bound to the Esc key by default (you can change it - see readline docs).
#
# Store the file in ~/.pystartup, and set an environment variable to point
# to it: "export PYTHONSTARTUP=~/.pystartup" in bash.
import atexit
import os
#import readline
#import rlcompleter
historyPath = os.path.expanduser("~/.pyhistory")
def save_history(historyPath=historyPath):
import readline
readline.write_history_file(historyPath)
if os.path.exists(historyPath):
#import readline
readline.read_history_file(historyPath)
atexit.register(save_history)
del os, atexit, readline, rlcompleter, save_history, historyPath
I don't see why which python3.8 and PYTHONPATH were out of sync:
$ cygpath -w $(which python3.8)
C:\Users\user1\Documents\appls_mydocs\PortableApps\MSYS2Portable\App\msys32\mingw64\bin\python3.8.exe
$ echo $PYTHONPATH
/c/Users/user1/Documents/appls_mydocs/PortableApps/MSYS2Portable/App/msys32/mingw64/lib/python3.8:/c/Users/user1/Documents/appls_mydocs/PortableApps/MSYS2Portable/App/msys32/mingw64/lib/python3.8/site-packages
$ cygpath -w /c/Users/user1/Documents/appls_mydocs/PortableApps/MSYS2Portable/App/msys32/mingw64/lib/python3.8
C:\Users\user1\Documents\appls_mydocs\PortableApps\MSYS2Portable\App\msys32\mingw64\lib\python3.8
$ cygpath -w /c/Users/user1/Documents/appls_mydocs/PortableApps/MSYS2Portable/App/msys32/mingw64/lib/python3.8/site-packages
C:\Users\user1\Documents\appls_mydocs\PortableApps\MSYS2Portable\App\msys32\mingw64\lib\python3.8\site-packages
$ which python
/usr/bin/python
I seem to have two incomplete/broken python installations (3.7, 3.8).
I don't know what led to an "incomplete" upgrade.
A couple of observations (see code below):
python points to 3.7
readline is available for 3.7 and not for 3.8.
I don't know why.
pandas (and many others) is available for 3.8 and not for 3.7.
Many of them won't import in 3.8 anyway, due to missing dependencies (which I guess are available in 3.7).
I don't know why.
python3.8 reports the location of .pythonrc in Windows format, while 3.7 reports it in Cygwin format.
Is that normal?
Removing PYTHONPATH does not help.
$ unset PYTHONPATH
$ python3.8
Python 3.8.2 (default, Apr 9 2020, 13:17:39) [GCC 9.3.0 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
Reading C:/Users/user1/Documents/appls_mydocs/PortableApps/MSYS2Portable/App/msys32/home/user1/.pythonrc
Module readline not available.
Traceback (most recent call last):
File "C:/Users/user1/Documents/appls_mydocs/PortableApps/MSYS2Portable/App/msys32/home/user1/.pythonrc", line 42, in <module>
del os, atexit, readline, rlcompleter, save_history, historyPath
NameError: name 'readline' is not defined
>>> import pandas
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:/Users/user1/Documents/appls_mydocs/PortableApps/MSYS2Portable/App/msys32/mingw64/lib/python3.8/site-packages/pandas/__init__.py", line 16, in <module>
raise ImportError(
ImportError: Unable to import required dependencies:
numpy: DLL load failed while importing _ctypes: No se puede encontrar el módulo especificado.
>>> exit()
Error in atexit._run_exitfuncs:
Traceback (most recent call last):
File "<frozen importlib._bootstrap>", line 991, in _find_and_load
File "<frozen importlib._bootstrap>", line 973, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'readline'
$ python
Python 3.7.4 (default, Jul 11 2019, 10:29:54)
[GCC 9.1.0] on msys
Type "help", "copyright", "credits" or "license" for more information.
Reading /home/user1/.pythonrc
readline is in /usr/lib/python3.7/lib-dynload/readline.cpython-37m.dll
>>> import pandas
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'pandas'
>>> exit()
EDIT #4:
I checked for all python packages, and I found something strange. It seems the basic python installation comprises two separate packages, one mingw64 and another msys.
I wouldn't know what does each one do.
$ pacman -Sl | grep "python" | grep "installed"
...
mingw64 mingw-w64-x86_64-python 3.8.2-2 [installed]
...
msys python 3.8.2-1 [installed: 3.7.4-1]
...
On one hand, there was a mismatch in installed versions mingw64 (3.8.2-2) vs msys (3.7.4-1).
On the other hand, the subversions available are not exactly the same for both (3.8.2-2) vs (3.8.2-1).
Anyway, I proceeded upgrading msys python, and this fixed things significantly.
$ pacman -S python
...
$ python
Python 3.8.2 (default, Apr 16 2020, 15:31:48)
[GCC 9.3.0] on msys
Type "help", "copyright", "credits" or "license" for more information.
Reading /home/user1/.pythonrc
Traceback (most recent call last):
File "/home/user1/.pythonrc", line 9, in <module>
import readline
File "/c/Users/user1/Documents/appls_mydocs/PortableApps/MSYS2Portable/App/msys32/mingw64/lib/python3.8/site-packages/readline.py", line 6, in <module>
from pyreadline.rlmain import Readline
File "/c/Users/user1/Documents/appls_mydocs/PortableApps/MSYS2Portable/App/msys32/mingw64/lib/python3.8/site-packages/pyreadline/__init__.py", line 12, in <module>
from . import logger, clipboard, lineeditor, modes, console
File "/c/Users/user1/Documents/appls_mydocs/PortableApps/MSYS2Portable/App/msys32/mingw64/lib/python3.8/site-packages/pyreadline/clipboard/__init__.py", line 13, in <module>
from .win32_clipboard import GetClipboardText, SetClipboardText
File "/c/Users/user1/Documents/appls_mydocs/PortableApps/MSYS2Portable/App/msys32/mingw64/lib/python3.8/site-packages/pyreadline/clipboard/win32_clipboard.py", line 37, in <module>
import ctypes.wintypes as wintypes
File "/c/Users/user1/Documents/appls_mydocs/PortableApps/MSYS2Portable/App/msys32/mingw64/lib/python3.8/ctypes/wintypes.py", line 20, in <module>
class VARIANT_BOOL(ctypes._SimpleCData):
ValueError: _type_ 'v' not supported
Failed calling sys.__interactivehook__
Traceback (most recent call last):
File "/c/Users/user1/Documents/appls_mydocs/PortableApps/MSYS2Portable/App/msys32/mingw64/lib/python3.8/site.py", line 412, in register_readline
import readline
File "/c/Users/user1/Documents/appls_mydocs/PortableApps/MSYS2Portable/App/msys32/mingw64/lib/python3.8/site-packages/readline.py", line 6, in <module>
from pyreadline.rlmain import Readline
File "/c/Users/user1/Documents/appls_mydocs/PortableApps/MSYS2Portable/App/msys32/mingw64/lib/python3.8/site-packages/pyreadline/__init__.py", line 12, in <module>
from . import logger, clipboard, lineeditor, modes, console
File "/c/Users/user1/Documents/appls_mydocs/PortableApps/MSYS2Portable/App/msys32/mingw64/lib/python3.8/site-packages/pyreadline/clipboard/__init__.py", line 13, in <module>
from .win32_clipboard import GetClipboardText, SetClipboardText
File "/c/Users/user1/Documents/appls_mydocs/PortableApps/MSYS2Portable/App/msys32/mingw64/lib/python3.8/site-packages/pyreadline/clipboard/win32_clipboard.py", line 37, in <module>
import ctypes.wintypes as wintypes
File "/c/Users/user1/Documents/appls_mydocs/PortableApps/MSYS2Portable/App/msys32/mingw64/lib/python3.8/ctypes/wintypes.py", line 20, in <module>
class VARIANT_BOOL(ctypes._SimpleCData):
ValueError: _type_ 'v' not supported
So I have readline in 3.8 now. But there is another issue that pops up during loading of .pythonrc.
Plus, there is a problem with numpy.
It does not stem from the python version (/usr/bin/python points now to 3.8).
$ python --version
Python 3.8.2
$ python
...
>>> import numpy
Traceback (most recent call last):
File "/c/Users/user1/Documents/appls_mydocs/PortableApps/MSYS2Portable/App/msys32/mingw64/lib/python3.8/site-packages/numpy/core/__init__.py", line 24, in <module>
from . import multiarray
File "/c/Users/user1/Documents/appls_mydocs/PortableApps/MSYS2Portable/App/msys32/mingw64/lib/python3.8/site-packages/numpy/core/multiarray.py", line 14, in <module>
from . import overrides
File "/c/Users/user1/Documents/appls_mydocs/PortableApps/MSYS2Portable/App/msys32/mingw64/lib/python3.8/site-packages/numpy/core/overrides.py", line 7, in <module>
from numpy.core._multiarray_umath import (
ModuleNotFoundError: No module named 'numpy.core._multiarray_umath'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/c/Users/user1/Documents/appls_mydocs/PortableApps/MSYS2Portable/App/msys32/mingw64/lib/python3.8/site-packages/numpy/__init__.py", line 142, in <module>
from . import core
File "/c/Users/user1/Documents/appls_mydocs/PortableApps/MSYS2Portable/App/msys32/mingw64/lib/python3.8/site-packages/numpy/core/__init__.py", line 54, in <module>
raise ImportError(msg)
ImportError:
IMPORTANT: PLEASE READ THIS FOR ADVICE ON HOW TO SOLVE THIS ISSUE!
Importing the numpy c-extensions failed.
- Try uninstalling and reinstalling numpy.
- If you have already done that, then:
1. Check that you expected to use Python3.8 from "/usr/bin/python.exe",
and that you have no directories in your PATH or PYTHONPATH that can
interfere with the Python and numpy version "1.18.3" you're trying to use.
2. If (1) looks fine, you can open a new issue at
https://github.com/numpy/numpy/issues. Please include details on:
- how you installed Python
- how you installed numpy
- your operating system
- whether or not you have multiple versions of Python installed
- if you built from source, your compiler versions and ideally a build log
- If you're working with a numpy git repository, try `git clean -xdf`
(removes all files not under version control) and rebuild numpy.
Note: this error has many possible causes, so please don't comment on
an existing issue about this - open a new one instead.
Original error was: No module named 'numpy.core._multiarray_umath'
EDIT #5
As per #a_guest suggestion, and pointing me to "ValueError: _type_ 'v' not supported" error after installing PyReadline, I removed pyreadline, and this problem is gone.
Now the only remaining issue seems to be that numpy cannot load, possibly (but not certainly) due to two alternative python 3.8 systems present.
So the questions now is: Msys2: Two python installations?
The ImportError: cannot import name 'open_code' from 'io' (unknown location) comes from the fact that there are two different versions of Python conflicting with each other. python still points to the old version 3.7 but PYTHONPATH got updated to point to the new 3.8 version. As the documentation of PYTHONPATH states, it becomes prepended to the module search path and hence shadows any builtin modules:
The default search path is installation dependent, but generally begins with prefix/lib/pythonversion (see PYTHONHOME above). It is always appended to PYTHONPATH.
You can reproduce that behavior by creating two different virtual environments and then start one while having PYTHONPATH point to the other. In the following I used Miniconda to create two different environments, py37 and py38, containing a 3.7 and 3.8 installation respectively.
(py37) user#pc:~$ python --version
Python 3.7.6
(py37) user#pc:~$ PYTHONPATH=~/miniconda3/envs/py38/lib/python3.8/ python
Fatal Python error: init_sys_streams: can't initialize sys standard streams
Traceback (most recent call last):
File "/home/user/miniconda3/envs/py38/lib/python3.8/io.py", line 54, in <module>
ImportError: cannot import name 'open_code' from 'io' (unknown location)
Aborted (core dumped)

PyXNAT Error while importing in python3.4

I have installed a package pyxnat on python3.4. i have installed required dependencies like httplib2 package and lxml correctly. but still when i import pyxnat i get following error.
bash-3.2$ python3.4
Python 3.4.2 (v3.4.2:ab2c023a9432, Oct 5 2014, 20:42:22)
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from pyxnat import Interface
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/sdb99/usr/lib/python2.7/site-packages/pyxnat/__init__.py", line 13, in <module>
from .core import Interface
File "/Users/sdb99/usr/lib/python2.7/site-packages/pyxnat/core/__init__.py", line 4, in <module>
from .interfaces import Interface
File "/Users/sdb99/usr/lib/python2.7/site-packages/pyxnat/core/interfaces.py", line 19, in <module>
from .select import Select
File "/Users/sdb99/usr/lib/python2.7/site-packages/pyxnat/core/select.py", line 4, in <module>
from .search import Search
File "/Users/sdb99/usr/lib/python2.7/site-packages/pyxnat/core/search.py", line 15, in <module>
from .errors import is_xnat_error, catch_error
File "/Users/sdb99/usr/lib/python2.7/site-packages/pyxnat/core/errors.py", line 31
except Exception, e:
^
SyntaxError: invalid syntax
Any suggestions to correct this?
Thanks!
EDIT:
In python 2.7 i get the following error
>>> myXNAT = Interface('https://hd-hni-xnat.cac.berkley.edu:8443/xnat')
User: sdb356
Password:
(<type 'exceptions.IOError'>, 'interfaces.py', '')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/sdb99/usr/lib/python2.7/site-packages/pyxnat/core/interfaces.py", line 228, in __init__
self._get_entry_point()
File "/Users/sdb99/usr/lib/python2.7/site-packages/pyxnat/core/interfaces.py", line 271, in _get_entry_point
raise e
IOError: [Errno 13] Permission denied
I tried looking into interfaces.py to understand the error but wasnt..
You have installed pyxnat for python2 and are trying to import it in the python3 interpreter, you have also somehow managed to add your python 2 path to your python 3 path.

keep getting 'ImportError: No module named pygtk' when I try to run Gaphor on windows

I have installed pygtk-all-in-one-2.24.0.win32-py2.7.msi on windows, and installed gaphor by easy_install. When I try to run gaphor, I receive an import error.
PS C:\Python27\Scripts> .\gaphor.exe
Traceback (most recent call last):
File "C:\Python27\Scripts\gaphor-script.py", line 9, in <module>
load_entry_point('gaphor==0.17.2', 'console_scripts', 'gaphor')()
File "build\bdist.win32\egg\pkg_resources\__init__.py", line 521, in load_entry_point
File "build\bdist.win32\egg\pkg_resources\__init__.py", line 2632, in load_entry_point
File "build\bdist.win32\egg\pkg_resources\__init__.py", line 2312, in load
File "build\bdist.win32\egg\pkg_resources\__init__.py", line 2318, in resolve
File "C:\Python27\lib\site-packages\gaphor-0.17.2-py2.7.egg\gaphor\__init__.py", line 13, in <module>
import pygtk
ImportError: No module named pygtk
Any suggestions would be appreciated!
Did you actually install pygtk? I suspect easy-install should have pulled it in automatically. Did you see any errors during the install? pygtk also requieres installing gtk+.
Do a simple test - start Python in a console (ipython?), and type:
$ python
Python 2.7.6 (default, May 6 2014, 10:57:58)
[GCC 4.8.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import pygtk
>>> import gtk
>>>
There should be no error messages.
You can also search the disk for pygtk.py (with the file manager) and for a directory gtk-2.0 or gtk-3.0.

Having trouble installing Dropbox API for Python 2.6

I have python 2.6 on Windows. I just installed Dropbox API and when I do:
import dropbox
It gives an error:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "build\bdist.win32\egg\dropbox\__init__.py", line 3, in <module>
# $Id$
File "build\bdist.win32\egg\dropbox\client.py", line 22, in <module>
File "C:\Python26\lib\site-packages\dropbox-2.2.0-py2.6.egg\dropbox\rest.py", line 415
utf8_params = {encode(k): encode(v) for k, v in params.iteritems()}
What can i do?
Reproducible also on Linux:
#> python
Python 2.6.5 (r265:79063, May 6 2011, 16:17:46)
[GCC 4.5.0 20100604 [gcc-4_5-branch revision 160292]] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import dropbox
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.6/site-packages/dropbox-2.2.0-py2.6.egg/dropbox/__init__.py", line 3, in <module>
from . import client, rest, session
File "/usr/local/lib/python2.6/site-packages/dropbox-2.2.0-py2.6.egg/dropbox/client.py", line 22, in <module>
from .rest import ErrorResponse, RESTClient, params_to_urlencoded
File "/usr/local/lib/python2.6/site-packages/dropbox-2.2.0-py2.6.egg/dropbox/rest.py", line 415
utf8_params = {encode(k): encode(v) for k, v in params.iteritems()}
^
SyntaxError: invalid syntax
I was desperate to get it working on 2.6 as I can't upgrade to latest versions of python. Finally got it working.
All you need to do is change the dictionary comprehension
From:
utf8_params = {encode(k): encode(v) for k, v in params.iteritems()}
To:
for k, v in params.iteritems():
utf8_params[encode(k)] = encode(v)
And rest of the module worked as usual so far.
I don't have the rep to add a comment so adding as an answer :)
This is definitely related to Python 2.6. The install-script of Dropbox's Python SDK is already throwing syntax errors when you run it with Python 2.6. Strangely, it keeps running and finishes regardless. Dropbox is not very specific about the required minimal version of Python, but the install-script suggests 2.6. Nevertheless, importing the Dropbox module will fail both on Windows and Linux due to a syntax error.
I just installed Python 2.7.9 in parallel to my original Python 2.6.5 environment. With 2.7, the Dropbox SDK installs and loads without any syntax error at at.

scipy with enthought canopy

I am evaluating the Enthought package. I installed the 32bit canopy (downloaded from https://www.enthought.com/downloads/) in Ubuntu.
$ sudo bash canopy-1.0.1-rh5-32.sh
Upon testing I don't see scipy in /usr/local/Canopy/appdata/canopy-1.0.0.1160.rh5-x86/lib/python2.7/site-packages:
$ /usr/local/Canopy/appdata/canopy-1.0.0.1160.rh5-x86/bin/python
Enthought Canopy Python 2.7.3 | 32-bit | (default, Mar 25 2013, 15:45:37)
[GCC 4.1.2 20080704 (Red Hat 4.1.2-52)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import scipy
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named scipy
>>> from pylab import*
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/Canopy/appdata/canopy-1.0.0.1160.rh5-x86/lib/python2.7/site-packages/pylab.py", line 1, in <module>
from matplotlib.pylab import *
File "/usr/local/Canopy/appdata/canopy-1.0.0.1160.rh5-x86/lib/python2.7/site-packages/matplotlib/pylab.py", line 265, in <module>
from matplotlib.pyplot import *
File "/usr/local/Canopy/appdata/canopy-1.0.0.1160.rh5-x86/lib/python2.7/site-packages/matplotlib/pyplot.py", line 97, in <module>
_backend_mod, new_figure_manager, draw_if_interactive, _show = pylab_setup()
File "/usr/local/Canopy/appdata/canopy-1.0.0.1160.rh5-x86/lib/python2.7/site-packages/matplotlib/backends/__init__.py", line 25, in pylab_setup
globals(),locals(),[backend_name])
File "/usr/local/Canopy/appdata/canopy-1.0.0.1160.rh5-x86/lib/python2.7/site-packages/matplotlib/backends/backend_wxagg.py", line 23, in <module>
import backend_wx # already uses wxversion.ensureMinimal('2.8')
File "/usr/local/Canopy/appdata/canopy-1.0.0.1160.rh5-x86/lib/python2.7/site-packages/matplotlib/backends/backend_wx.py", line 52, in <module>
raise ImportError(missingwxversion)
ImportError: Matplotlib backend_wx and backend_wxagg require wxversion, which was not found.
Please help me: how can install the Python Canopy (including scipy, matplotlib etc.)? Do I have to manually install them? I thought the installer shell script installed all these automatically. Am I missing something?
$ uname -a
Linux sree 3.0.0-32-generic-pae #51-Ubuntu SMP Thu Mar 21 16:09:48 UTC 2013 i686 i686 i386 GNU/Linux
Scipy is installed into a different virtual environment (~/Enthought/Canopy_64bit/System/). In general, you should be running the Python available at ~/Enthought/Canopy_64bit/User/bin/python as described here. Also look at this article for information on how to make Canopy your default Python

Categories

Resources