首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >模块安装,但不能导入。

模块安装,但不能导入。
EN

Stack Overflow用户
提问于 2017-12-31 21:25:40
回答 1查看 545关注 0票数 1

我对Python很陌生,我试图在Mac上运行一个依赖于模块的Python2脚本,我已经安装了这个模块,但是根据脚本无法找到。为什么下面的失败?

代码语言:javascript
复制
Home:Dev m$ python -V
Python 2.7.10
Home:Dev m$ sudo pip install coincurve==5.2.0 pysha3
Password:
The directory '/Users/m/Library/Caches/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 '/Users/m/Library/Caches/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 coincurve==5.2.0
  Downloading coincurve-5.2.0-cp27-cp27m-macosx_10_6_intel.whl (157kB)
    100% |████████████████████████████████| 163kB 1.3MB/s 
Collecting pysha3
  Downloading pysha3-1.0.2.tar.gz (829kB)
    100% |████████████████████████████████| 829kB 692kB/s 
Requirement already satisfied: cffi>=1.3.0 in /usr/local/lib/python2.7/site-packages (from coincurve==5.2.0)
Requirement already satisfied: asn1crypto in /usr/local/lib/python2.7/site-packages (from coincurve==5.2.0)
Requirement already satisfied: pycparser in /usr/local/lib/python2.7/site-packages (from cffi>=1.3.0->coincurve==5.2.0)
Installing collected packages: coincurve, pysha3
  Running setup.py install for pysha3 ... done
Successfully installed coincurve-5.2.0 pysha3-1.0.2
Home:Dev m$ pip show coincurve
Name: coincurve
Version: 5.2.0
Summary: Cross-platform Python CFFI bindings for libsecp256k1
Home-page: https://github.com/ofek/coincurve
Author: Ofek Lev
Author-email: ofekmeister@gmail.com
License: MIT/Apache-2.0
Location: /usr/local/lib/python2.7/site-packages
Requires: cffi, asn1crypto
Home:Dev m$ python
Python 2.7.10 (default, Jul 15 2017, 17:16:57) 
[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 coincurve
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named coincurve
>>> 
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2017-12-31 21:37:04

问题是,实际上您并不在python2.7shell中。在某些Linux发行版中,您必须指定python版本才能进入其shell。因此,运行以下命令:

代码语言:javascript
复制
python2

而不是:

代码语言:javascript
复制
python

因为上面的命令会自动打开python3.xshell。

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/48045752

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档