我不知道如何修复此问题。请提出解决方案:
mona@pascal:~$ sudo chmod -R 777 /home/mona/.cache/pip/
mona@pascal:~$ sudo ls -l /home/mona/.cache/
total 68
drwxr-xr-x 3 mona mona 4096 Sep 30 16:21 bazel
drwx------ 2 root root 4096 Jan 18 22:19 dconf
drwx------ 8 mona mona 4096 Jan 17 12:12 evolution
drwxr-xr-x 2 mona mona 4096 Nov 8 16:37 fontconfig
drwxrwxr-x 2 mona mona 4096 Jan 25 01:31 gstreamer-1.0
drwxrwxr-x 3 mona mona 4096 Jan 17 12:03 ibus
-rw-rw-r-- 1 mona mona 2279 Jan 17 12:12 indicator-applet-complete.log
drwxrwxr-x 2 mona mona 4096 Jan 19 07:44 logrotate
drwxrwxr-x 3 mona mona 4096 Feb 3 21:36 matplotlib
-rw-r--r-- 1 mona mona 0 Aug 30 17:41 motd.legal-displayed
drwx------ 3 mona mona 4096 Jan 25 17:56 mozilla
drwxrwxr-x 3 mona mona 4096 Jan 17 12:34 oneconf
drwxrwxrwx 4 777 mona 4096 Jan 31 16:39 pip
drwxrwxr-x 2 mona mona 4096 Jan 17 12:35 sso
drwx------ 4 mona mona 4096 Oct 18 14:44 thumbnails
drwxr-xr-x 2 mona mona 4096 Jan 19 16:16 tracker
drwxrwxr-x 2 mona mona 4096 Jan 17 12:14 update-manager-core
drwx------ 2 mona mona 4096 Jan 19 16:16 upstart
mona@pascal:~$ sudo pip2 install cffi
The directory '/home/mona/.cache/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
The directory '/home/mona/.cache/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Requirement already satisfied: cffi in /usr/local/lib/python2.7/dist-packages
Requirement already satisfied: pycparser in /usr/local/lib/python2.7/dist-packages (from cffi)
/usr/local/lib/python2.7/dist-packages/pip/_vendor/requests/packages/urllib3/util/ssl_.py:318: SNIMissingWarning: An HTTPS request has been made, but the SNI (Subject Name Indication) extension to TLS is not available on this platform. This may cause the server to present an incorrect TLS certificate, which can cause validation failures. You can upgrade to a newer version of Python to solve this. For more information, see https://urllib3.readthedocs.io/en/latest/security.html#snimissingwarning.
SNIMissingWarning
/usr/local/lib/python2.7/dist-packages/pip/_vendor/requests/packages/urllib3/util/ssl_.py:122: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. You can upgrade to a newer version of Python to solve this. For more information, see https://urllib3.readthedocs.io/en/latest/security.html#insecureplatformwarning.
InsecurePlatformWarning
我试图运行 Jupyter 笔记本,但出现了这个问题:
mona@pascal:~$ jupyter notebook
Traceback (most recent call last):
File "/usr/local/bin/jupyter-notebook", line 7, in <module>
from notebook.notebookapp import main
File "/usr/local/lib/python2.7/dist-packages/notebook/notebookapp.py", line 31, in <module>
from zmq.eventloop import ioloop
File "/usr/lib/python2.7/dist-packages/zmq/__init__.py", line 62, in <module>
from zmq.backend import *
File "/usr/lib/python2.7/dist-packages/zmq/backend/__init__.py", line 22, in <module>
_ns = select_backend('zmq.backend.cffi')
File "/usr/lib/python2.7/dist-packages/zmq/backend/select.py", line 31, in select_backend
mod = __import__(name, fromlist=public_api)
ImportError: No module named cffi
我安装了 python-cffi 但它仍然显示“没有名为 cffi 的模块”:
mona@pascal:~$ sudo apt-get install python-cffi
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following package was automatically installed and is no longer required:
libxine1-bin
Use 'apt-get autoremove' to remove it.
The following extra packages will be installed:
python-ply python-pycparser
Suggested packages:
python-ply-doc
The following NEW packages will be installed:
python-cffi python-ply python-pycparser
0 upgraded, 3 newly installed, 0 to remove and 65 not upgraded.
Need to get 170 kB of archives.
After this operation, 956 kB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 http://us.archive.ubuntu.com/ubuntu/ trusty/main python-ply all 3.4-3ubuntu2 [48.1 kB]
Get:2 http://us.archive.ubuntu.com/ubuntu/ trusty/universe python-pycparser all 2.10+dfsg-1ubuntu2 [55.5 kB]
Get:3 http://us.archive.ubuntu.com/ubuntu/ trusty/universe python-cffi amd64 0.8.2-0ubuntu1 [66.2 kB]
Fetched 170 kB in 0s (603 kB/s)
Selecting previously unselected package python-ply.
(Reading database ... 326746 files and directories currently installed.)
Preparing to unpack .../python-ply_3.4-3ubuntu2_all.deb ...
Unpacking python-ply (3.4-3ubuntu2) ...
Selecting previously unselected package python-pycparser.
Preparing to unpack .../python-pycparser_2.10+dfsg-1ubuntu2_all.deb ...
Unpacking python-pycparser (2.10+dfsg-1ubuntu2) ...
Selecting previously unselected package python-cffi.
Preparing to unpack .../python-cffi_0.8.2-0ubuntu1_amd64.deb ...
Unpacking python-cffi (0.8.2-0ubuntu1) ...
Processing triggers for man-db (2.6.7.1-1ubuntu1) ...
Setting up python-ply (3.4-3ubuntu2) ...
Setting up python-pycparser (2.10+dfsg-1ubuntu2) ...
Setting up python-cffi (0.8.2-0ubuntu1) ...
我很困惑该做什么:
mona@pascal:~$ sudo apt-get install ipython-notebook
Reading package lists... Done
Building dependency tree
Reading state information... Done
ipython-notebook is already the newest version.
The following package was automatically installed and is no longer required:
libxine1-bin
Use 'apt-get autoremove' to remove it.
0 upgraded, 0 newly installed, 0 to remove and 65 not upgraded.
mona@pascal:~$ python
Python 2.7.6 (default, Oct 26 2016, 20:30:19)
[GCC 4.8.4] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import cffi
>>> quit()
mona@pascal:~$ jupyter notebook
Traceback (most recent call last):
File "/usr/local/bin/jupyter-notebook", line 7, in <module>
from notebook.notebookapp import main
File "/usr/local/lib/python2.7/dist-packages/notebook/notebookapp.py", line 31, in <module>
from zmq.eventloop import ioloop
File "/usr/lib/python2.7/dist-packages/zmq/__init__.py", line 62, in <module>
from zmq.backend import *
File "/usr/lib/python2.7/dist-packages/zmq/backend/__init__.py", line 22, in <module>
_ns = select_backend('zmq.backend.cffi')
File "/usr/lib/python2.7/dist-packages/zmq/backend/select.py", line 31, in select_backend
mod = __import__(name, fromlist=public_api)
ImportError: No module named cffi
mona@pascal:~$ sudo -H pip2 install cffi
Requirement already satisfied: cffi in /usr/local/lib/python2.7/dist-packages
Requirement already satisfied: pycparser in /usr/local/lib/python2.7/dist-packages (from cffi)
mona@pascal:~$ sudo -H pip install cffi
Requirement already satisfied: cffi in /usr/local/lib/python3.4/dist-packages
Requirement already satisfied: pycparser in /usr/local/lib/python3.4/dist-packages (from cffi)
mona@pascal:~$ jupyter --version
4.2.1
事实证明,由于同样的问题,我无法导入 zmq。我甚至从头开始构建 zmq 并制作,没有任何错误,但仍然收到相同的错误:
mona@pascal:~/libzmq/cmake-build$ python
Python 2.7.6 (default, Oct 26 2016, 20:30:19)
[GCC 4.8.4] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import zmq
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.7/dist-packages/zmq/__init__.py", line 62, in <module>
from zmq.backend import *
File "/usr/lib/python2.7/dist-packages/zmq/backend/__init__.py", line 22, in <module>
_ns = select_backend('zmq.backend.cffi')
File "/usr/lib/python2.7/dist-packages/zmq/backend/select.py", line 31, in select_backend
mod = __import__(name, fromlist=public_api)
ImportError: No module named cffi
$ python -c "import zmq.backend.cython"
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/usr/lib/python2.7/dist-packages/zmq/__init__.py", line 62, in <module>
from zmq.backend import *
File "/usr/lib/python2.7/dist-packages/zmq/backend/__init__.py", line 22, in <module>
_ns = select_backend('zmq.backend.cffi')
File "/usr/lib/python2.7/dist-packages/zmq/backend/select.py", line 31, in select_backend
mod = __import__(name, fromlist=public_api)
ImportError: No module named cffi
$ pip2 show ipython pyzmq
Name: ipython
Version: 5.1.0
Summary: IPython: Productive Interactive Computing
Home-page: http://ipython.org
Author: The IPython Development Team
Author-email: [email protected]
License: BSD
Location: /usr/local/lib/python2.7/dist-packages
Requires: backports.shutil-get-terminal-size, setuptools, decorator, pickleshare, simplegeneric, pexpect, pathlib2, traitlets, prompt-toolkit, pygments
---
Name: pyzmq
Version: 14.0.1
Summary: Python bindings for 0MQ
Home-page: http://github.com/zeromq/pyzmq
Author: Brian E. Granger, Min Ragan-Kelley
Author-email: [email protected]
License: LGPL+BSD
Location: /usr/lib/python2.7/dist-packages
Requires:
答案1
问题还没有完全解决,但至少那个错误已经修复。基本上安装了 pyzmq:
mona@pascal:~/libzmq/cmake-build$ python
Python 2.7.6 (default, Oct 26 2016, 20:30:19)
[GCC 4.8.4] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import zmq
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named zmq
>>> quit()
mona@pascal:~/libzmq/cmake-build$ sudo pip2 install pyzmq
The directory '/home/mona/.cache/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
The directory '/home/mona/.cache/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Collecting pyzmq
/usr/local/lib/python2.7/dist-packages/pip/_vendor/requests/packages/urllib3/util/ssl_.py:318: SNIMissingWarning: An HTTPS request has been made, but the SNI (Subject Name Indication) extension to TLS is not available on this platform. This may cause the server to present an incorrect TLS certificate, which can cause validation failures. You can upgrade to a newer version of Python to solve this. For more information, see https://urllib3.readthedocs.io/en/latest/security.html#snimissingwarning.
SNIMissingWarning
/usr/local/lib/python2.7/dist-packages/pip/_vendor/requests/packages/urllib3/util/ssl_.py:122: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. You can upgrade to a newer version of Python to solve this. For more information, see https://urllib3.readthedocs.io/en/latest/security.html#insecureplatformwarning.
InsecurePlatformWarning
Downloading pyzmq-16.0.2-cp27-cp27mu-manylinux1_x86_64.whl (3.0MB)
100% |████████████████████████████████| 3.0MB 335kB/s
Installing collected packages: pyzmq
Successfully installed pyzmq-16.0.2
mona@pascal:~/libzmq/cmake-build$ python
Python 2.7.6 (default, Oct 26 2016, 20:30:19)
[GCC 4.8.4] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import zmq
>>> quit()
mona@pascal:~/libzmq/cmake-build$ jupyter notebook
Traceback (most recent call last):
File "/usr/local/bin/jupyter-notebook", line 7, in <module>
from notebook.notebookapp import main
File "/usr/local/lib/python2.7/dist-packages/notebook/notebookapp.py", line 27, in <module>
from jinja2 import Environment, FileSystemLoader
ImportError: No module named jinja2