![在 Python 中安装随机时出现问题](https://linux22.com/image/1156579/%E5%9C%A8%20Python%20%E4%B8%AD%E5%AE%89%E8%A3%85%E9%9A%8F%E6%9C%BA%E6%97%B6%E5%87%BA%E7%8E%B0%E9%97%AE%E9%A2%98.png)
我正在使用 python 2.7.4,运行时遇到问题pip install random
。出现以下错误:
Collecting random
Could not find a version that satisfies the requirement random (from versions: )
No matching distribution found for random
有人能帮我解决这件事吗?
结果pip install -vvv random # verbose output
:
File "c:\users\support-ihsan\app\lib\site-packages\pip_internal\req\req_install.py", line 307, in populate_link self.link = finder.find_requirement(self, upgrade)
File "c:\users\support-ihsan\app\lib\site-packages\pip_internal\index.py", line 533, in find_requirement 'No matching distribution found for %s' % req DistributionNotFound: No matching distribution found for random
答案1
这意味着没有名为 random 的包。
随机模块也应该默认存在。因为此代码在装有 python2 的机器上运行良好
import random
num = random.randint(10,20)
print (num)
当我输入此命令时,我也遇到了同样的错误
pip install random