Advertisement

Python中遇到的错误总结:Smart contract Vulnerability Detection Using Graph Neural Network

阅读量:

问题:Cannot open Local Terminal Failed to start [powershell.exe] in D:\Thesis experiment

解决办法:
我在Pycharm2021中打开Terminal页面时,显示Cannot open Local Terminal的问题,可以试着点击File------Settings…------Tools------Terminal将其中的Shell path中的powershell.exe更改为cmd.exe

问题:can’t convert non-string with explicit base

解决办法
将String使用“”括起来
将String,h=”0x…“使用“”括起来

pip在更新时,更新失败,旧版pip被删除但新版我未安装。

解决办法
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
python -m ensurepip
python -m pip install --upgrade pip

问题:tensorflow have no attribute enable_eager_execution()

解决办法
2.0 版本 移除 了直接调用 enable_eager_execution() 的方式。
原因:新版本将 enable_eager_execution() 放入了 compat.v1 内部。

复制代码
    # tensorflow >= 1.5
    tf.compat.v1.enable_eager_execution() 
     
    # tensorflow >= 1.4 <2.0
    tf.enable_eager_execution() 
     
    # tensorflow >= 2.0
    以上都免了,也可以使用第一个

问题:cannot import name ‘args‘ from ‘parser‘ (unknown location) windows

解决办法
将parser.py模块全部换了个名,改为了parser1.py,中间所有parser都换为了parser1

问题:ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()

问题:int() argument must be a string, a bytes-like object or a number, not ‘NoneType’

解决办法:
源代码:
random_seed = args.get('--random_seed')
self.random_seed = int(random_seed)
threshold = args.get('--thresholds')
self.threshold = float(threshold)
修改后的源码:
random_seed = args.get('--random_seed')
self.random_seed = random_seed
threshold = args.get('--thresholds')
self.threshold = threshold

问题:AttributeError: module ‘tensorflow’ has no attribute ‘ConfigProto’

解决办法:
因为在tf2.0后不适用源码:
config = tf.ConfigProto()
所以我们将原来的代码替换成以下代码:
config = tf.compat.v1.ConfigProto()

问题:AttributeError: module ‘tensorflow’ has no attribute ‘Session’

解决办法:
因为在tf2.0后不适用源码:
config = tf.Session()
所以我们将原来的代码替换成以下代码:
config = tf.compat.v1.Session()

问题:AttributeError: module ‘tensorflow’ has no attribute ‘XXX’

解决办法:
因为在tf2.0后不适用源码:
config = tf.XXX()
所以我们将原来的代码替换成以下代码:
config = tf.compat.v1.XXX()

TypeError: init() got an unexpected keyword argument ‘size‘ 和TypeError: init() got an unexpected keyword argument ‘iter‘的问题

解决办法,由于gensim版本不同引发的参数类型错误,因此我们这里将一下代码参数变量进行更换。
修改前原代码在这里插入图片描述
修改后代码
在这里插入图片描述

TypeError: Got an unexpected keyword argument ‘keep_dims‘错误

解决办法
错误原代码在这里插入图片描述
修改后代码
在这里插入图片描述

全部评论 (0)

还没有任何评论哟~