Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

在我的机器上运行您的程序时,我把涉及 google.colab的代码注释掉,结果出现如下错误,请问是这么回事? #1

Closed
2017wxyzwxyz opened this issue Dec 18, 2020 · 2 comments

Comments

@2017wxyzwxyz
Copy link

注释掉的代码

from google.colab import drive

drive.mount('/content/drive')

import os

path = "/content/drive/My Drive/SaicAILab"

os.chdir(path)

运行错误:发生在 ’预训练模型图解‘处:
from IPython.display import SVG
from keras.utils.vis_utils import model_to_dot

SVG(model_to_dot(ae_model,show_shapes= True, show_layer_names=True, dpi=65).create(prog='dot', format='svg'))

错误提示:
('Failed to import pydot. You must pip install pydot and install graphviz (https://graphviz.gitlab.io/download/), ', 'for pydotprint to work.')

AttributeError Traceback (most recent call last)
in
2 from keras.utils.vis_utils import model_to_dot
3
----> 4 SVG(model_to_dot(ae_model,show_shapes= True, show_layer_names=True, dpi=65).create(prog='dot', format='svg'))

AttributeError: 'NoneType' object has no attribute 'create'

根据提示我安装好了pydot和graphviz 两个包后,重新运行,结果还是出同样的错:
控制台输出如下:

(Keras) F:\AnalyticsZoo\UberPaperimplement>pip install pydot
Collecting pydot
Downloading pydot-1.4.1-py2.py3-none-any.whl (19 kB)
Requirement already satisfied: pyparsing>=2.1.4 in c:\users\wxy\anaconda3\envs\keras\lib\site-packages (from pydot) (2.4.7)
Installing collected packages: pydot
Successfully installed pydot-1.4.1

(Keras) F:\AnalyticsZoo\UberPaperimplement>pip install graphviz
Collecting graphviz
Downloading graphviz-0.15-py2.py3-none-any.whl (18 kB)
Installing collected packages: graphviz
Successfully installed graphviz-0.15

(Keras) F:\AnalyticsZoo\UberPaperimplement>jupyter notebook
[I 12:28:27.235 NotebookApp] Serving notebooks from local directory: F:\AnalyticsZoo\UberPaperimplement
[I 12:28:27.236 NotebookApp] Jupyter Notebook 6.1.5 is running at:
[I 12:28:27.238 NotebookApp] http://localhost:8888/?token=d754dc8d300c895d6009fe14a08f530ac339d74dc5b2522b
[I 12:28:27.242 NotebookApp] or http://127.0.0.1:8888/?token=d754dc8d300c895d6009fe14a08f530ac339d74dc5b2522b
[I 12:28:27.243 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
[C 12:28:27.293 NotebookApp]

To access the notebook, open this file in a browser:
    file:///C:/Users/wxy/AppData/Roaming/jupyter/runtime/nbserver-16972-open.html
Or copy and paste one of these URLs:
    http://localhost:8888/?token=d754dc8d300c895d6009fe14a08f530ac339d74dc5b2522b
 or http://127.0.0.1:8888/?token=d754dc8d300c895d6009fe14a08f530ac339d74dc5b2522b

[I 12:28:33.832 NotebookApp] Kernel started: 9de98f90-7991-4cec-86ce-9814f3a1fb6e, name: python3
2020-12-18 12:28:54.044539: I tensorflow/core/platform/cpu_feature_guard.cc:142] This TensorFlow binary is optimized with oneAPI Deep Neural Network Library (oneDNN)to use the following CPU instructions in performance-critical operations: AVX AVX2
To enable them in other operations, rebuild TensorFlow with the appropriate compiler flags.
[I 12:30:33.767 NotebookApp] Saving file at /Deep_and_Confident_Prediction_for_Time_Series_at_Uber.ipynb

jupyter notebook 输出如下:

预训练模型图解
In [15]:

from IPython.display import SVG
from keras.utils.vis_utils import model_to_dot

SVG(model_to_dot(ae_model,show_shapes= True, show_layer_names=True, dpi=65).create(prog='dot', format='svg'))
('Failed to import pydot. You must pip install pydot and install graphviz (https://graphviz.gitlab.io/download/), ', 'for pydotprint to work.')

AttributeError Traceback (most recent call last)
in
2 from keras.utils.vis_utils import model_to_dot
3
----> 4 SVG(model_to_dot(ae_model,show_shapes= True, show_layer_names=True, dpi=65).create(prog='dot', format='svg'))

AttributeError: 'NoneType' object has no attribute 'create'

请教如何解决此问题?多谢!

@QuanhanSun
Copy link
Owner

QuanhanSun commented Dec 21, 2020 via email

@Ambitioner-c
Copy link

我也遇到了大概相似的问题(已解决)


我遇到问题和解决问题的过程如下:

  • 在jupyter上运行如下代码之前没有问题

from google.colab import drive
drive.mount('/content/drive')

  • 在导入google.colab之后jupyter无法再使用了

显示:ValueError: signal only works in main thread

  • 在这篇博客找到了问题所在

《jupyter notebook中出现ValueError: signal only works in main thread 报错 即 长时间in[*] 解决办法》https://blog.csdn.net/jackhh1/article/details/103435550

  • 上文未给出解决方案,参考另一篇博客找到了解决方案

《Jupyter Notebook "signal only works in main thread"》
https://blog.csdn.net/loovelj/article/details/82184223

  • 采用了其中一部分教程

大概如下:
pip uninstall google.colab
pip install "pyzmq==17.0.0" "ipykernel==4.8.2"
pip install pydot


总得来说

from google.colab import drive
drive.mount('/content/drive')

import os
path = "/content/drive/My Drive/SaicAILab"
os.chdir(path)

这些代码似乎都没有用,我把它们注释之后整体运行是没有错误的!!!
@2017wxyzwxyz

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants