我在我的Digitalocean Ubuntu Droplet上遇到一个非常奇怪的问题,其中Python 2.7给出了以下错误:
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android">
<data>
<import type="org.honorato.diagnostics.models.Check"/>
<variable
name="check"
type="Check"/>
</data>
<LinearLayout
android:background="@android:color/white"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="72dp"
>
<LinearLayout
android:padding="16dp"
android:layout_width="0dip"
android:layout_weight="1"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:text="@{check.title}"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="@android:color/primary_text_light"
android:textStyle="bold" />
</LinearLayout>
<ImageView
android:padding="16dp"
android:src="@{check.getStatusDrawable(check.status)}"
android:background="@{check.getStatusColor(check.status)}"
android:layout_width="72dp"
android:layout_height="match_parent"
android:layout_gravity="center_vertical|center_horizontal" />
</LinearLayout>
</layout>
事实上,我无法用Python做任何:
from instagram import InstagramAuthentication, InstagramAPI
File "/root/instagram_insights/socialgraphs-final-assignment/instagram.py", line 1, in <module>
import requests
File "/usr/lib/python2.7/dist-packages/requests/__init__.py", line 55, in <module>
import urllib3
File "/usr/lib/python2.7/dist-packages/urllib3/__init__.py", line 10, in <module>
from .connectionpool import (
File "/usr/lib/python2.7/dist-packages/urllib3/connectionpool.py", line 2, in <module>
import logging
ImportError: No module named logging
重新安装python,我会收到相同的错误apt-get
,我收到错误pip search logging
创建新的virtualenv而不会出现同样的错误我的virtualenv venv
看起来像这样:
PYTHONPATH
有趣的是,在我重新启动gunicorn之前,错误一直出现,这是我用来托管我的Flask网站的WSGI服务器。
在它发生之前,我正在摆弄
['', '/usr/local/lib/python2.7/dist-packages/gunicorn-19.3.0-py2.7.egg', '/usr/lib/python2.7/dist-packages', '/usr/lib/python2.7', '/usr/lib/python2.7/plat-x86_64-linux-gnu', '/usr/lib/python2.7/lib-tk', '/usr/lib/python2.7/lib-old', '/usr/lib/python2.7/lib-dynload', '/usr/local/lib/python2.7/dist-packages']
中的日志,但是我无法看到它应该如何影响我的Python安装。
答案 0 :(得分:2)
确保使用系统范围的python而不是virtualenv-from-some:
which python
尝试找出此模块的位置:
sudo updatedb
locate logging | grep python
然后尝试将此路径添加到PYTHONPATH