我在安装了pysnooper之后,运行github上的例子:
import pysnooper
@ pysnooper.snoop()
def number_to_bits(number):
if number:
bits = []
while number:
number,remainder = divmod(number,2)
bits.insert(0,remainder)
return bits
else:
return [ 0 ]
number_to_bits(6)
错误:
PS E:\PYTHON\pace 2> & E:/Anaconda3/python.exe "e:/PYTHON/pace 2/1.py"
Traceback (most recent call last):
File "e:/PYTHON/pace 2/1.py", line 3, in <module>
@ pysnooper.snoop()
AttributeError: module 'pysnooper' has no attribute 'snoop'
在网上找了各种方法都没能解决~
找到问题所在啦,我把python转移到了e盘,也配置了对应的环境变量。但是还没删除之前存在的环境变量,这导致就连pip都会直接去找C盘,即使pysnooper是安装在e盘的,但在运行时候也会出错。说到底这就是环境变量冲突的问题,幸好旁边有一个老程序猿在帮忙解决了qwq