我尝试在我的项目中创建一个新数据库,但是当我运行脚本时遇到了这个错误,我有另一个使用类似定义的项目,它之前有效,但现在它得到了同样的错误.我使用的是Python 2.7.8,SQLAlchemy模块的版本是0.9.8.顺便说一句,一个项目使用Flask-SQLAlchemy,它运行良好.我很迷惑.回溯信息如下:
Traceback (most recent call last):
File "D:/Projects/OO-IM/db_create.py", line 4, in <module>
from models import Base
File "D:\Projects\OO-IM\models.py", line 15, in <module>
Column('followed_id', Integer(), ForeignKey('user.id'))
File "C:\Python27\lib\site-packages\sqlalchemy\sql\schema.py", line 369, in __new__
schema = metadata.schema
File "C:\Python27\lib\site-packages\sqlalchemy\sql\elements.py", line 662, in __getattr__
key)
AttributeError: Neither 'Column' object nor 'Comparator' object has an attribute 'schema'
from sqlalchemy import create_engine, Column, String, Integer, Text, DateTime, Boolean, ForeignKey, Table
from sqlalchemy.orm import sessionmaker, relationship, backref
from sqlalchemy.ext.declarative import declarative_base
SQLALCHEMY_DATABASE_URI = "mysql://root:mysqladmin@localhost:3306/oo_im?charset=utf8"
Base = …Run Code Online (Sandbox Code Playgroud) 我刚刚下载了 pytube(版本 11.0.1)并从这里开始使用以下代码片段:
from pytube import YouTube
YouTube('https://youtu.be/9bZkp7q19f0').streams.first().download()
Run Code Online (Sandbox Code Playgroud)
这给出了这个错误:
AttributeError Traceback (most recent call last)
<ipython-input-29-0bfa08b87614> in <module>
----> 1 YouTube('https://youtu.be/9bZkp7q19f0').streams.first().download()
~/anaconda3/lib/python3.8/site-packages/pytube/__main__.py in streams(self)
290 """
291 self.check_availability()
--> 292 return StreamQuery(self.fmt_streams)
293
294 @property
~/anaconda3/lib/python3.8/site-packages/pytube/__main__.py in fmt_streams(self)
175 # https://github.com/pytube/pytube/issues/1054
176 try:
--> 177 extract.apply_signature(stream_manifest, self.vid_info, self.js)
178 except exceptions.ExtractError:
179 # To force an update to the js file, we clear the cache and retry
~/anaconda3/lib/python3.8/site-packages/pytube/extract.py in apply_signature(stream_manifest, vid_info, js)
407
408 """
--> 409 cipher = …Run Code Online (Sandbox Code Playgroud) 我想使用最新版本的 pyvis 和 python 版本 3.9.6 进行网络可视化:
from pyvis.network import Network
g = Network()
g.add_node(0)
g.add_node(1)
g.add_edge(0, 1)
g.show('test.html')
Run Code Online (Sandbox Code Playgroud)
每次执行时g.show()我都会收到此错误:
Traceback (most recent call last):
File "/Users/tom/Library/Mobile Documents/com~apple~CloudDocs/Projekte/Coding_/f1 standings/test2.py", line 3, in <module>
g.show('nx.html')
File "/Users/tom/Library/Python/3.9/lib/python/site-packages/pyvis/network.py", line 546, in show
self.write_html(name, open_browser=False,notebook=True)
File "/Users/tom/Library/Python/3.9/lib/python/site-packages/pyvis/network.py", line 515, in write_html
self.html = self.generate_html(notebook=notebook)
File "/Users/tom/Library/Python/3.9/lib/python/site-packages/pyvis/network.py", line 479, in generate_html
self.html = template.render(height=height,
AttributeError: 'NoneType' object has no attribute 'render'
Run Code Online (Sandbox Code Playgroud)
我尝试更新 pyvis,更改了代码中的各种详细信息,并导入了所有 pyvis.network,但没有任何结果。
我昨天安装了一个条带包,现在我的应用程序没有运行.我试图了解问题所在.有什么事情做PyShell或HTLParser或别的东西.我发布了GAE标签,希望日志中的跟踪可以提供有关问题的线索:
MLStripper instance has no attribute 'rawdata'
Traceback (most recent call last):
File "/base/python_runtime/python_lib/versions/1/google/appengine/ext/webapp/_webapp25.py", line 703, in __call__
handler.post(*groups)
File "/base/data/home/apps/ting-1/1.354723388329082800/ting.py", line 2070, in post
pitch_no_tags = strip_tags(pitch_original)
File "/base/data/home/apps/ting-1/1.354723388329082800/ting.py", line 128, in strip_tags
s.feed(html)
File "/base/python_runtime/python_dist/lib/python2.5/HTMLParser.py", line 107, in feed
self.rawdata = self.rawdata + data
AttributeError: MLStripper instance has no attribute 'rawdata'
Run Code Online (Sandbox Code Playgroud)
这是MLStripper:
from HTMLParser import HTMLParser
class MLStripper(HTMLParser):
def __init__(self):
set()
self.fed = []
def handle_data(self, d):
self.fed.append(d)
def get_data(self):
return ''.join(self.fed)
def strip_tags(html): …Run Code Online (Sandbox Code Playgroud) 我查找了所有"'Tensor'对象没有属性***"但似乎没有任何与Keras有关(除了TensorFlow:AttributeError:'Tensor'对象没有属性'log10'没有帮助)...
我正在制作一种GAN(Generative Adversarial Networks).在这里你可以找到结构.
Layer (type) Output Shape Param # Connected to
_____________________________________________________________________________
input_1 (InputLayer) (None, 30, 91) 0
_____________________________________________________________________________
model_1 (Model) (None, 30, 1) 12558 input_1[0][0]
_____________________________________________________________________________
model_2 (Model) (None, 30, 91) 99889 input_1[0][0]
model_1[1][0]
_____________________________________________________________________________
model_3 (Model) (None, 1) 456637 model_2[1][0]
_____________________________________________________________________________
Run Code Online (Sandbox Code Playgroud)
我预先训练了model_2和model_3.事情是我预先训练了model_2,列表由0和1组成,但是model_1返回了接近的值.所以我考虑使用以下代码舍入model1_output:model1_out上的K.round().
import keras.backend as K
[...]
def make_gan(GAN_in, model1, model2, model3):
model1_out = model1(GAN_in)
model2_out = model2([GAN_in, K.round(model1_out)])
GAN_out = model3(model2_out)
GAN = Model(GAN_in, GAN_out)
GAN.compile(loss=loss, optimizer=model1.optimizer, metrics=['binary_accuracy'])
return GAN
[...]
Run Code Online (Sandbox Code Playgroud)
我有以下错误:
AttributeError:'Tensor'对象没有属性'_keras_history'
完全追溯: …
我有一个不同植物物种的数据集,我将每个物种分成不同的物种np.array.
当试图从这些物种中生成高斯模型时,我不得不计算每个不同标签的平均值和协方差矩阵.
问题是:当np.cov()在其中一个标签中使用时,该函数会引发错误"'float'对象没有属性'shape'",我无法确定问题的来源.我正在使用的确切代码行如下:
covx = np.cov(label0, rowvar=False)
Run Code Online (Sandbox Code Playgroud)
哪个label0是numpy ndarray of shape(50,3),其中列代表不同的变量,每行是不同的观察.
确切的错误跟踪是:
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-81-277aa1d02ff0> in <module>()
2
3 # Get the covariances
----> 4 np.cov(label0, rowvar=False)
C:\Users\Matheus\Anaconda3\lib\site-packages\numpy\lib\function_base.py in cov(m, y, rowvar, bias, ddof, fweights, aweights)
3062 w *= aweights
3063
-> 3064 avg, w_sum = average(X, axis=1, weights=w, returned=True)
3065 w_sum = w_sum[0]
3066
C:\Users\Matheus\Anaconda3\lib\site-packages\numpy\lib\function_base.py in average(a, axis, weights, returned)
1143
1144 if returned:
-> 1145 if scl.shape …Run Code Online (Sandbox Code Playgroud) 如何修复此错误我从GitHub下载了此代码.
predicted_id = tf.multinomial(tf.exp(predictions), num_samples=1)[0][0].numpy()
Run Code Online (Sandbox Code Playgroud)
抛出错误
AttributeError: 'Tensor' object has no attribute 'numpy'
Run Code Online (Sandbox Code Playgroud)
请帮我解决这个问题!
我用了:
sess = tf.Session()
with sess.as_default():
predicted_id = tf.multinomial(tf.exp(predictions), num_samples=1)[0][0].eval()
Run Code Online (Sandbox Code Playgroud)
我得到这个错误.有人帮助我,我只是想让它工作为什么这么难?
D:\Python>python TextGenOut.py
File "TextGenOut.py", line 72
predicted_id = tf.multinomial(tf.exp(predictions), num_samples=1)[0][0].eval()
^
IndentationError: unexpected indent
D:\Python>python TextGenOut.py
2018-09-16 21:50:57.008663: I T:\src\github\tensorflow\tensorflow\core\platform\cpu_feature_guard.cc:141] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2
2018-09-16 21:50:57.272973: W T:\src\github\tensorflow\tensorflow\core\framework\op_kernel.cc:1275] OP_REQUIRES failed at resource_variable_ops.cc:480 : Not found: Container localhost does not exist. (Could not find resource: localhost/model/embedding/embeddings) …Run Code Online (Sandbox Code Playgroud) 我对编程完全陌生,我正在尝试使用 Python 来使用 Pythin 读取 CSV 文件。我正在使用 Spyder 执行此操作。我收到错误“模块‘datetime’没有属性‘strptime’”,并且无法弄清楚。任何帮助将不胜感激。这是我的代码:
import os
import csv
from datetime import datetime
path=csvpath=os.path.join("..","Practice","Google Stock Market Data -
google_stock_data.csv")
file=open(path,newline="")
reader=csv.reader(file)
header=next(reader)
data=[]
Run Code Online (Sandbox Code Playgroud)
对于读卡器中的行:
date=datetime.strptime(row[0], '%m/%d/%y')
Run Code Online (Sandbox Code Playgroud)
这是我收到的错误消息。
date=datetime.strptime(row[0], '%m/%d/%y')
AttributeError: module 'datetime' has no attribute 'strptime'
Run Code Online (Sandbox Code Playgroud) 我花了半天时间试图自己解决这个问题,但现在我已经没有想法和谷歌搜索请求了。所以基本上我想要的是使用 package.json 连接到我们的 Snowflake 数据库snowflake-connector-python。我能够很好地安装该软件包(以及自动安装的所有相关软件包),我当前的pip3 list结果是:
Package Version
-------------------------- ---------
asn1crypto 1.3.0
azure-common 1.1.25
azure-core 1.6.0
azure-storage-blob 12.3.2
boto3 1.13.26
botocore 1.16.26
certifi 2020.6.20
cffi 1.14.0
chardet 3.0.4
cryptography 2.9.2
docutils 0.15.2
gitdb 4.0.5
GitPython 3.1.3
idna 2.9
isodate 0.6.0
jmespath 0.10.0
msrest 0.6.17
oauthlib 3.1.0
oscrypto 1.2.0
pip 20.1.1
pyasn1 0.2.3
pyasn1-modules 0.0.9
pycparser 2.20
pycryptodomex 3.9.8
PyJWT 1.7.1
pyOpenSSL 19.1.0
python-dateutil 2.8.1
pytz 2020.1
requests 2.23.0
requests-oauthlib 1.3.0
s3transfer 0.3.3
setuptools 47.3.1
six 1.15.0 …Run Code Online (Sandbox Code Playgroud) 首先,对这两个问题的明显程度表示道歉; 我对此非常陌生,并且不知道我在做什么.
我正在尝试编写一些内容来将样条插值的Scipy函数应用于值数组.我的代码目前看起来像这样:
import numpy as np
import scipy as sp
from scipy.interpolate import interp1d
x=var
x1 = ([0.1,0.3,0.4])
y1 = [0.2,0.5,0.6]
new_length = 25
new_x = np.linspace(x.min(), x.max(), new_length)
new_y = sp.interpolate.interp1d(x, y, kind='cubic')(new_x)
Run Code Online (Sandbox Code Playgroud)
但当它到达线
new_x = np.linspace(x.min(), x.max(), new_length)
Run Code Online (Sandbox Code Playgroud)
我收到以下错误:
AttributeError: 'function' object has no attribute 'min'
Run Code Online (Sandbox Code Playgroud)
到目前为止,谷歌搜索等没有发现任何我理解的内容.这是什么意思,我该如何解决?
第二个问题:如何一次输入多行代码?目前,如果我尝试复制整个内容然后将其粘贴到PyLab中,它只输入我的代码的顶行,所以我必须一次将整个内容粘贴到一行中.我怎么绕这个?
attributeerror ×10
python ×9
numpy ×3
arrays ×1
attributes ×1
datetime ×1
html ×1
html-parsing ×1
keras ×1
networkx ×1
python-3.x ×1
pytube ×1
pyvis ×1
snowflake-cloud-data-platform ×1
sqlalchemy ×1
strptime ×1
tensor ×1
tensorflow ×1