Python sandman2库报错module ‘time‘ has no attribute ‘clock‘ 或 无法将“sandman2”项识别为 cmdlet、函数、脚本文件或可运行程序的名称

在Windows环境下安装sandman2 可能会在pip install sanman2后出现

sandman2 : 无法将“sandman2”项识别为 cmdlet、函数、脚本文件或可运行程序的名称。
请检查名称的拼写,如果包括路径,请确保路径正确,然后再试一次

这时候你需要看一下在pip时是否有类似这样的警告

WARNING: The script sandman2ctl.exe is installed in 'C:\Users\xxx\AppData\Roaming\Python\Python38\Scripts' which is not on PATH.
  Consider adding this directory to PATH or, if you prefer to suppress this warning, 
use --no-warn-script-location.


这时候你需要将绿色的路径加入系统的环境变量即可调用sandman2ctl

如果在调用sandman2ctl报如下错误
 

 File "c:\programdata\anaconda3\lib\runpy.py", line 194, in _run_module_as_main
    return _run_code(code, main_globals, None,
····
  File "C:\Users\xxx\AppData\Roaming\Python\Python38\site-packages\sqlalchemy\util\_collections.py", line 16, in < from .compat import binary_types
  File "C:\Users\xxx\AppData\Roaming\Python\Python38\site-packages\sqlalchemy\util\compat.py", line 331, in <module>
    time_func = time.clock
AttributeError: module 'time' has no attribute 'clock'

请将文件定位到 C:\Users\xxx\AppData\Roaming\Python\Python38\site-packages\sqlalchemy\util\compat.py   

compat.py 这个文件,打开它 做如下修改:

第331行代码

# 修改前
if win32 or jython:
    time_func = time.clock # ← 替换为time.perf_counter()
else:
    time_func = time.time
# 修改后
if win32 or jython:
    time_func = time.perf_counter()
else:
    time_func = time.time

该错误的原因是python3.8不在有对clock的支持

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值