Yesterday updated my ubuntu 17.04 to ubuntu 17.10. any comments? Appear when I try to run server in pycharm. #django project.
bash -cl "/home/encuentrum/venv-encuentrum3/bin/python /usr/share/pycharm/helpers/pycharm/django_manage.py check /home/encuentrum/GitLab/encuentrum3/ENCUENTRUM/packers_"
Traceback (most recent call last):
File "/usr/share/pycharm/helpers/pycharm/django_manage.py", line 5, in <module>
from pycharm_run_utils import adjust_django_sys_path
File "/usr/share/pycharm/helpers/pycharm/pycharm_run_utils.py", line 4, in <module>
import imp
File "/home/encuentrum/venv-encuentrum3/lib/python3.6/imp.py", line 19, in <module>
from importlib._bootstrap import _ERR_MSG, _exec, _load, _builtin_from_name
File "/home/encuentrum/venv-encuentrum3/lib/python3.6/importlib/__init__.py", line 57, in <module>
import types
File "/home/encuentrum/venv-encuentrum3/lib/python3.6/types.py", line 171, in <module>
import functools as _functools
File "/home/encuentrum/venv-encuentrum3/lib/python3.6/functools.py", line 23, in <module>
from weakref import WeakKeyDictionary
File "/home/encuentrum/venv-encuentrum3/lib/python3.6/weakref.py", line 12, in <module>
from _weakref import (
ImportError: cannot import name '_remove_dead_weakref'
Maybe you have mixed your multiple Python installations, the newer version of weakref are not compatible with older version python binary, try to remove any one (the older one is recommended) of Python installation.
Analysis
For my case, I have installed older version Python (3.5.1) before, and upgrade my Debian installation. The newer Debian upgrade it's Python3.5 to 3.5.3 which have _remove_dead_weakref in _weakref in its Python binary
When I type $ where python3.5, I get
/usr/local/bin/python3.5
/usr/local/bin/python3.5
/usr/bin/python3.5
The /usr/local/bin/python3.5 is my own older installation, and /usr/bin/python3.5 is Debian offical Python3.5
When I update my Python3.5 installation by apt-get, apt-get execute python3.5 -E -S /usr/lib/python3.5/py_compile.py $files (post-install script) in the deb package.`, it triggers the weakref issue, here is my log
Setting up python3.5-minimal (3.5.3-1+deb9u1) ...
Traceback (most recent call last):
File "/usr/lib/python3.5/py_compile.py", line 6, in <module>
import importlib._bootstrap_external
File "/usr/lib/python3.5/importlib/__init__.py", line 57, in <module>
import types
File "/usr/lib/python3.5/types.py", line 166, in <module>
import functools as _functools
File "/usr/lib/python3.5/functools.py", line 23, in <module>
from weakref import WeakKeyDictionary
File "/usr/lib/python3.5/weakref.py", line 12, in <module>
from _weakref import (
ImportError: cannot import name '_remove_dead_weakref'
I tested Python 3.5.1 and Python 3.5.3 with same import action, here are the compares
Official Python 3.5.3 from apt-get
Python 3.5.3 (default, Sep 27 2018, 17:25:39)
[GCC 6.3.0 20170516] on linux
>>> from _weakref import _remove_dead_weakref
>>>
My own Python 3.5.1 installation
Python 3.5.1 (default, Apr 23 2016, 16:40:21)
[GCC 4.9.2] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>
>>> from _weakref import _remove_dead_weakref
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: cannot import name '_remove_dead_weakref'
>>>
So, I confirm that python3.5 in /usr/local/bin/ cannot use _remove_dead_weakref.
But which python did apt-get use in post-installation script? Try it.
$ which python3.5
/usr/local/bin/python3.5
So, here is why. The post-installation script use my custom installation of python, along with newer python library (/usr/lib/python3.5/weakref.py)
Fix it!
As I said, disable older version of python
sudo mv /usr/local/bin/python3.5 /usr/local/bin/python3.5.bak
Test
$ which python3.5
/usr/bin/python3.5
Adding to #Comzyh answer, this indeed is due to mixed python versions when an upgrade happen due to any reason. A quick fix is to remove your venv python binary i.e. rm <path-to-your-env>/bin/python and copying your system python binary to your venv like cp /usr/bin/python <path-to-your-env>/bin/python. This will fix the weak ref error
Related
I'm using python 3.5.2 (64 bit) within a operating system Linux Mint 18 with a kernel release 4.4.0-109-generic.
A long time ago I installed PyQt4 through sudo apt-get install python3-pyqt4 and everything worked perfectly, untill I recently installed through pip PyQt5.
Since then, I'm able to import PyQt4 and import PyQt4.pyqtconfig but not the modules like import PyQt4.QtCore, import PyQt4.QtGui or import PyQt4.Qt for which exits python with 'Segmentation Fault'. I've also realized that the command (within python enviroment) help('modules') gives same output after some seconds.
I've tried to remove PyQt5 with pip and reinstall PyQt4 from terminal (version 4.11.4+dfsg-1build4), but nothing seems to change. I also can see the directory from the PyQt4 from /usr/lib/python3/dist-packages/PyQt4
I've also tried to create a python virtual environment with virtualenv env --python=python3.5 inside a folder and copy the whole directory from PyQt4 to the dist-packages of the environment and also install sip within it. Using sip 4.19.8 version from pip.
Another thing I've tried is to use gdb python3 to run a python program that only contains the code:
#!/usr/bin/python3
import PyQt4.QtCore
What it returns is this:
$ gdb -q python3
Reading symbols from python3...Reading symbols from /usr/lib/debug/.build-id/59/a8ef36ca241df24686952480966d7bc0d7c6ea.debug...done.
done.
(gdb) run FaultPy35.py
Starting program: /usr/bin/python3 FaultPy35.py
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
Program received signal SIGSEGV, Segmentation fault.
PyType_IsSubtype () at ../Objects/typeobject.c:1343
1343 ../Objects/typeobject.c: No such file or directory.
(gdb) c
Continuing.
Program terminated with signal SIGSEGV, Segmentation fault.
The program no longer exists.
(gdb)
I'm really new to gdb but apparently the problem goes beyond python packages...
Note: I've checked via dpkg-query -L python3-pyqt4 what the package python3-pyqt4 has installed in the following list:
/.
/usr
/usr/share
/usr/share/doc
/usr/share/doc/python3-pyqt4
/usr/share/doc/python3-pyqt4/THANKS
/usr/share/doc/python3-pyqt4/copyright
/usr/share/doc/python3-pyqt4/changelog.Debian.gz
/usr/lib
/usr/lib/python3
/usr/lib/python3/dist-packages
/usr/lib/python3/dist-packages/PyQt4
/usr/lib/python3/dist-packages/PyQt4/QtHelp.cpython-35m-x86_64-linux-gnu.so
/usr/lib/python3/dist-packages/PyQt4/uic
/usr/lib/python3/dist-packages/PyQt4/uic/Compiler
/usr/lib/python3/dist-packages/PyQt4/uic/Compiler/qtproxies.py
/usr/lib/python3/dist-packages/PyQt4/uic/Compiler/proxy_metaclass.py
/usr/lib/python3/dist-packages/PyQt4/uic/Compiler/compiler.py
/usr/lib/python3/dist-packages/PyQt4/uic/Compiler/indenter.py
/usr/lib/python3/dist-packages/PyQt4/uic/Compiler/misc.py
/usr/lib/python3/dist-packages/PyQt4/uic/Compiler/qobjectcreator.py
/usr/lib/python3/dist-packages/PyQt4/uic/Compiler/__init__.py
/usr/lib/python3/dist-packages/PyQt4/uic/objcreator.py
/usr/lib/python3/dist-packages/PyQt4/uic/Loader
/usr/lib/python3/dist-packages/PyQt4/uic/Loader/loader.py
/usr/lib/python3/dist-packages/PyQt4/uic/Loader/qobjectcreator.py
/usr/lib/python3/dist-packages/PyQt4/uic/Loader/__init__.py
/usr/lib/python3/dist-packages/PyQt4/uic/driver.py
/usr/lib/python3/dist-packages/PyQt4/uic/properties.py
/usr/lib/python3/dist-packages/PyQt4/uic/uiparser.py
/usr/lib/python3/dist-packages/PyQt4/uic/pyuic.py
/usr/lib/python3/dist-packages/PyQt4/uic/port_v3
/usr/lib/python3/dist-packages/PyQt4/uic/port_v3/invoke.py
/usr/lib/python3/dist-packages/PyQt4/uic/port_v3/ascii_upper.py
/usr/lib/python3/dist-packages/PyQt4/uic/port_v3/proxy_base.py
/usr/lib/python3/dist-packages/PyQt4/uic/port_v3/load_plugin.py
/usr/lib/python3/dist-packages/PyQt4/uic/port_v3/as_string.py
/usr/lib/python3/dist-packages/PyQt4/uic/port_v3/string_io.py
/usr/lib/python3/dist-packages/PyQt4/uic/port_v3/__init__.py
/usr/lib/python3/dist-packages/PyQt4/uic/__init__.py
/usr/lib/python3/dist-packages/PyQt4/uic/widget-plugins
/usr/lib/python3/dist-packages/PyQt4/uic/widget-plugins/phonon.py
/usr/lib/python3/dist-packages/PyQt4/uic/widget-plugins/qtwebkit.py
/usr/lib/python3/dist-packages/PyQt4/uic/widget-plugins/qtdeclarative.py
/usr/lib/python3/dist-packages/PyQt4/uic/widget-plugins/.noinit
/usr/lib/python3/dist-packages/PyQt4/uic/widget-plugins/qaxcontainer.py
/usr/lib/python3/dist-packages/PyQt4/uic/widget-plugins/qscintilla.py
/usr/lib/python3/dist-packages/PyQt4/uic/icon_cache.py
/usr/lib/python3/dist-packages/PyQt4/uic/exceptions.py
/usr/lib/python3/dist-packages/PyQt4/QtSvg.cpython-35m-x86_64-linux-gnu.so
/usr/lib/python3/dist-packages/PyQt4/Qt.cpython-35m-x86_64-linux-gnu.so
/usr/lib/python3/dist-packages/PyQt4/pyqtconfig.py
/usr/lib/python3/dist-packages/PyQt4/QtScriptTools.cpython-35m-x86_64-linux-gnu.so
/usr/lib/python3/dist-packages/PyQt4/pyqtconfig_nd5.py
/usr/lib/python3/dist-packages/PyQt4/QtDesigner.cpython-35m-x86_64-linux-gnu.so
/usr/lib/python3/dist-packages/PyQt4/QtCore.cpython-35m-x86_64-linux-gnu.so
/usr/lib/python3/dist-packages/PyQt4/QtDeclarative.cpython-35m-x86_64-linux-gnu.so
/usr/lib/python3/dist-packages/PyQt4/QtGui.cpython-35m-x86_64-linux-gnu.so
/usr/lib/python3/dist-packages/PyQt4/QtNetwork.cpython-35m-x86_64-linux-gnu.so
/usr/lib/python3/dist-packages/PyQt4/QtXml.cpython-35m-x86_64-linux-gnu.so
/usr/lib/python3/dist-packages/PyQt4/QtWebKit.cpython-35m-x86_64-linux-gnu.so
/usr/lib/python3/dist-packages/PyQt4/QtDBus.cpython-35m-x86_64-linux-gnu.so
/usr/lib/python3/dist-packages/PyQt4/QtAssistant.cpython-35m-x86_64-linux-gnu.so
/usr/lib/python3/dist-packages/PyQt4/__init__.py
/usr/lib/python3/dist-packages/PyQt4/QtXmlPatterns.cpython-35m-x86_64-linux-gnu.so
/usr/lib/python3/dist-packages/PyQt4/QtTest.cpython-35m-x86_64-linux-gnu.so
/usr/lib/python3/dist-packages/PyQt4/QtScript.cpython-35m-x86_64-linux-gnu.so
Any Ideas?
Update (25/04/18)
I tried the python 3.5 debug build at import time:
$ python3-dbg
Python 3.5.2 (default, Nov 23 2017, 16:37:01)
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import PyQt4
>>> import PyQt4.QtCore
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named 'PyQt4.QtCore'
Error in sys.excepthook:
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/apport_python_hook.py", line 63, in apport_excepthook
from apport.fileutils import likely_packaged, get_recent_crashes
File "/usr/lib/python3/dist-packages/apport/__init__.py", line 5, in <module>
from apport.report import Report
File "/usr/lib/python3/dist-packages/apport/report.py", line 30, in <module>
import apport.fileutils
File "/usr/lib/python3/dist-packages/apport/fileutils.py", line 23, in <module>
from apport.packaging_impl import impl as packaging
File "/usr/lib/python3/dist-packages/apport/packaging_impl.py", line 23, in <module>
import apt
File "/usr/lib/python3/dist-packages/apt/__init__.py", line 23, in <module>
import apt_pkg
ImportError: No module named 'apt_pkg'
Original exception was:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named 'PyQt4.QtCore'
>>>
I am trying to use python-mbus for python 3, i have installed it with
sudo apt-get install python3-dbus
However the import fails with:
asdf#asdf:~$ python3
Python 3.6.3 (default, Oct 3 2017, 21:16:13)
[GCC 7.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import dbus
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.6/dist-packages/dbus/__init__.py", line 77, in <module>
import dbus.types as types
File "/usr/local/lib/python3.6/dist-packages/dbus/types.py", line 6, in <module>
from _dbus_bindings import (
ImportError: /usr/local/lib/python3.6/dist-packages/_dbus_bindings.so: undefined symbol: _Py_ZeroStruct
I have also installed it with:
pip3 uninstall dbus-python
But i still get the same error:
asdf#asdf:~$ python3
Python 3.6.3 (default, Oct 3 2017, 21:16:13)
[GCC 7.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import dbus
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/asdf/.local/lib/python3.6/site-packages/dbus/__init__.py", line 77, in <module>
import dbus.types as types
File "/home/asdf/.local/lib/python3.6/site-packages/dbus/types.py", line 6, in <module>
from _dbus_bindings import (
ImportError: /home/asdf/.local/lib/python3.6/site-packages/_dbus_bindings.so: undefined symbol: _Py_ZeroStruct
This is in sys.path:
>>> print (sys.path)
['', '/usr/lib/python36.zip', '/usr/lib/python3.6', '/usr/lib/python3.6/lib-dynload', '/home/asdf/.local/lib/python3.6/site-packages', '/usr/local/lib/python3.6/dist-packages', '/usr/lib/python3/dist-packages', '/usr/lib/python3.6/dist-packages']
Im runnin on Debian GNU/Linux buster/sid
Any idea of what am I doing wrong?
I'm not exactly sure how I fixed this (can't comment), but I had the exact same problem and I did:
sudo pip3 uninstall dbus-python
sudo aptitude update && sudo aptitude upgrade
sudo aptitude -f
After which aptitude alerted me of some dependency issues with Python, and I "downgraded" a version of Python I had installed on Ubuntu Xenial to the default package provided by Artful. Now, import dbus on Python 3.6.3 doesn't pass any errors. Don't know if it actually works well, though.
Maybe you'll be able to fix it in a similar fashion, since Debian and Ubuntu packages are usually the same.
Python 2.7.10 on win32. windows 8.1
used pip to install geocoder library https://pypi.python.org/pypi/geocoder/1.8.0
get this error when I try and import the library
>>> import geocoder
Traceback (most recent call last):
File "<interactive input>", line 1, in <module>
File "C:\Python27\ArcGIS10.4\lib\site-packages\geocoder\__init__.py", line 36, in <module>
from geocoder.api import get, yahoo, bing, geonames, mapquest, google, mapbox # noqa
File "C:\Python27\ArcGIS10.4\lib\site-packages\geocoder\api.py", line 29, in <module>
from geocoder.freegeoip import FreeGeoIP
File "C:\Python27\ArcGIS10.4\lib\site-packages\geocoder\freegeoip.py", line 6, in <module>
import ratelim
File "C:\Python27\ArcGIS10.4\lib\site-packages\ratelim\__init__.py", line 6, in <module>
from decorator import decorator
ImportError: No module named decorator
>>>
I thought just an install of the decorator library would fix the situtation but that library was already installed
C:\Python27\ArcGIS10.4\Scripts>pip install decorator
Requirement already satisfied: decorator in c:\python27\arcgis10.4\lib\site-packages
update
C:\Users\rizagha>python --version
Python 2.7.10
C:\Users\rizagha>python
Python 2.7.10 (default, May 23 2015, 09:44:00) [MSC v.1500 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from decorator import decorator
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named decorator
something that may be complicating this is I have python 32 bit and 64 bit installed via arcgis...
Try running the following command to install the module
[root#server] python -m pip install decorator
This should install the module to the python library of the interpreter that starts when you run the python command
then try start up your interpreter again and try to import the module (assuming it doesn't say it's already satisfied)
[root#server] python
>> from decorator import decorator
>>
if it does say that it's already satisfied, then you can try to uninstall it using pip and then reinstall it by explicitly specifying the python -m command
[root#server] pip uninstall decorator
[root#server] python -m pip install decorator
then you can check to see if the module is available in your default interpretor
[root#server] python
>> from decorator import decorator
>>
I am trying to test 3rd party code with Anaconda 4.2 / Python 3.5 When I execute tests I get following exception:
Traceback (most recent call last):
File "pyspark/sql/tests.py", line 25, in <module>
import subprocess
File "/home/user/anaconda3/lib/python3.5/subprocess.py", line 364, in <module>
import signal
File "/home/user/anaconda3/lib/python3.5/signal.py", line 3, in <module>
from functools import wraps as _wraps
File "/home/user/anaconda3/lib/python3.5/functools.py", line 22, in <module>
from types import MappingProxyType
File "/home/user/Spark/spark-2.1.0-bin-hadoop2.7/python/pyspark/sql/types.py", line 22, in <module>
import calendar
File "/home/user/anaconda3/lib/python3.5/calendar.py", line 10, in <module>
import locale as _locale
File "/home/user/anaconda3/lib/python3.5/locale.py", line 108, in <module>
#functools.wraps(_localeconv)
AttributeError: module 'functools' has no attribute 'wraps'
Normally I would assume some module is shadowing built-in modules but as far as I can tell this is not the issue:
I logged module path (functools.__file__) from the tests and it yields expected path. Also there is nothing strange in the path I get in the exception.
To exclude possible module corruption I tested completely new Anaconda installation.
When I execute tests, with the same configuration and path, from IPython shell (%run pyspark/sql/tests.py) problem disappears.
functools.wraps can be imported in the shell started in the same directory and with the same configuration.
When I replace Python 3 environment with Python 2 environment problem disappears.
Problem cannot be reproduced with environment create using virtualenv.
With different version of the same project I get:
Traceback (most recent call last):
File "pyspark/sql/tests.py", line 25, in <module>
import pydoc
File "/home/user/anaconda3/lib/python3.5/pydoc.py", line 55, in <module>
import importlib._bootstrap
File "/home/user/anaconda3/lib/python3.5/importlib/__init__.py", line 57, in <module>
import types
File "/home/user/Spark/spark-1.6.3-bin-hadoop2.6/python/pyspark/sql/types.py", line 22, in <module>
import calendar
File "/home/user/anaconda3/lib/python3.5/calendar.py", line 10, in <module>
import locale as _locale
File "/home/user/anaconda3/lib/python3.5/locale.py", line 19, in <module>
import functools
File "/home/user/anaconda3/lib/python3.5/functools.py", line 22, in <module>
from types import MappingProxyType
ImportError: cannot import name 'MappingProxyType'
Is there something obvious I missed here?
Edit:
Dockerfile which can be used to reproduce the problem:
FROM debian:latest
RUN apt-get update
RUN apt-get install -y wget bzip2
RUN wget https://repo.continuum.io/archive/Anaconda3-4.2.0-Linux-x86_64.sh
RUN bash Anaconda3-4.2.0-Linux-x86_64.sh -b -p /anaconda3
RUN wget ftp://ftp.piotrkosoft.net/pub/mirrors/ftp.apache.org/spark/spark-2.1.0/spark-2.1.0-bin-hadoop2.7.tgz
RUN tar xf spark-2.1.0-bin-hadoop2.7.tgz
ENV PATH /anaconda3/bin:$PATH
ENV SPARK_HOME /spark-2.1.0-bin-hadoop2.7
ENV PYTHONPATH $PYTHONPATH:$SPARK_HOME/python/lib/py4j-0.10.4-src.zip:$SPARK_HOME/python
WORKDIR /spark-2.1.0-bin-hadoop2.7
RUN python python/pyspark/sql/tests.py
I suspect this is happening because, the functools module of python3 has the following import: from types import MappingProxyType and, instead of picking up this module from ${CONDA_PREFIX}/lib/python3.5/types.py, it tries to import the module from inside the sql directory: ${SPARK_HOME}/python/pyspark/sql/types.py . The functools module of python2 does not have this import and hence does not throw the error.
A workaround to this, is to somehow import the required types module first and then invoke the script. As a proof of concept:
(root) ~/condaexpts$ PYTHONPATH=$SPARK_HOME/python/lib/py4j-0.10.4-src.zip:$SPARK_HOME/python python
Python 3.5.2 |Anaconda 4.2.0 (64-bit)| (default, Jul 2 2016, 17:53:06)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-1)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import types
>>> import os
>>> sqltests=os.environ['SPARK_HOME'] + '/python/pyspark/sql/tests.py'
>>> exec(open(sqltests).read())
.....Using Spark's default log4j profile: org/apache/spark/log4j-defaults.properties
Setting default log level to "WARN".
To adjust logging level use sc.setLogLevel(newLevel). For SparkR, use setLogLevel(newLevel).
17/01/30 05:59:43 WARN SparkContext: Support for Java 7 is deprecated as of Spark 2.0.0
17/01/30 05:59:44 WARN NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
...
----------------------------------------------------------------------
Ran 128 tests in 372.565s
Also note that there is nothing special about conda. One can see the same thing in a normal virtualenv (with python3):
~/condaexpts$ virtualenv -p python3 venv
Running virtualenv with interpreter /usr/bin/python3
Using base prefix '/usr'
New python executable in venv/bin/python3
Also creating executable in venv/bin/python
Installing setuptools, pip...done.
~/condaexpts$ source venv/bin/activate
(venv)~/condaexpts$ python --version
Python 3.4.3
(venv)~/condaexpts$ python $WORKDIR/python/pyspark/sql/tests.py
Traceback (most recent call last):
File "/home/ubuntu/condaexpts/spark-2.1.0-bin-hadoop2.7/python/pyspark/sql/tests.py", line 26, in <module>
import pydoc
File "/usr/lib/python3.4/pydoc.py", line 59, in <module>
import importlib._bootstrap
File "/home/ubuntu/condaexpts/venv/lib/python3.4/importlib/__init__.py", line 40, in <module>
import types
File "/home/ubuntu/condaexpts/spark-2.1.0-bin-hadoop2.7/python/pyspark/sql/types.py", line 22, in <module>
import calendar
File "/usr/lib/python3.4/calendar.py", line 10, in <module>
import locale as _locale
File "/home/ubuntu/condaexpts/venv/lib/python3.4/locale.py", line 20, in <module>
import functools
File "/home/ubuntu/condaexpts/venv/lib/python3.4/functools.py", line 22, in <module>
from types import MappingProxyType
ImportError: cannot import name 'MappingProxyType'
From command line I can't import appengine, this might be something with my python path:
$ python
Python 2.7.1+ (r271:86832, Apr 11 2011, 18:13:53)
[GCC 4.5.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from google.appengine.ext import db
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "google/appengine/ext/db/__init__.py", line 98, in <module>
from google.appengine.api import datastore
File "google/appengine/api/datastore.py", line 62, in <module>
from google.appengine.datastore import datastore_query
File "google/appengine/datastore/datastore_query.py", line 64, in <module>
from google.appengine.datastore import datastore_index
File "google/appengine/datastore/datastore_index.py", line 60, in <module>
from google.appengine.api import validation
File "google/appengine/api/validation.py", line 51, in <module>
import yaml
ImportError: No module named yaml
>>>
I don't want duplicate installations, I want to point the Python interpretor to where the missing module is. How do I make the interpretor find the app engine modules from the command prompt? In the application these imports are working.
appending:
/usr/local/google_appengine/:/usr/local/google_appengine/lib/:/usr/local/google_appengine/lib/yaml/
to your PYTHONPATH environment variable should do the trick (your SDK location may vary).
For appengine 1.9.6 google has created a new directory "yaml-3.10" that contains the yaml module. I added "[appengine install directory]/google_appengine/lib/yaml-3.10" to PYTHONPATH in my .bashrc file and that solved this problem. BTW: I use Ubuntu 14.04 LTS.
yaml is not installed in your current setup. yaml package is included with google_appengine in the lib folder. the setup.py script in the folder will add the yaml package to your current python
cd google_appengine/lib/yaml
sudo python setup.py install