gpt4 book ai didi

python - 模块已安装但无法导入

转载 作者:行者123 更新时间:2023-12-01 02:20:05 25 4
gpt4 key购买 nike

我是Python新手,我试图在Mac上运行一个Python2脚本,该脚本依赖于一个模块,我已经安装了该模块,但根据脚本找不到。为什么以下失败?

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
>>>

最佳答案

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

python2

而不是:

python

因为上面的命令会自动打开python 3.x shell。

关于python - 模块已安装但无法导入,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48045752/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com