我正在尝试使用Tensorflow对象检测API,并按照给定链接中提到的步骤操作-
https://tensorflow-object-detection-api-tutorial.readthedocs.io/en/latest/install.html#tf-models-install
当我尝试通过jupyter notebook
访问目标检测Jupyter笔记本时
我面临以下异常
Traceback (most recent call last):
File "/usr/local/bin/jupyter-notebook", line 7, in <module>
from notebook.notebookapp import main
File "/home/dinesh/.local/lib/python3.6/site-
packages/notebook/notebookapp.py", line 79, in <module>
from .base.handlers import Template404, RedirectWithParams
File "/home/dinesh/.local/lib/python3.6/site-
packages/notebook/base/handlers.py", line 32, in <module>
import prometheus_client
File "/home/dinesh/.local/lib/python3.6/site-
packages/prometheus_client/__init__.py", line 7, in <module>
from . import process_collector
File "/home/dinesh/.local/lib/python3.6/site-
packages/prometheus_client/process_collector.py", line 12, in <module>
_PAGESIZE = resource.getpagesize()
AttributeError: module 'resource' has no attribute 'getpagesize'
我在用
Python - 3.6.3
Jupyter - 1.0.0
我怎样才能克服这个异常?
5条答案
按热度按时间sgtfey8w1#
出现类似错误。我的项目包含模块(文件夹)
所以我将资源模块的名称改为resources(将name改为任何适当的模块名称)
hujrc8aj2#
我有同样的错误,重命名我的
resource
模块在PYTHONPATH
,它的工作权利。检查您的PYTHONPATH,有一个资源模块?uelo1irk3#
[快速查找根本原因]检查是否已在系统中设置PYTHONPATH-
1.尝试暂时重命名它
1.运行“jupyter笔记本”
[Fix问题]如果通过执行此操作解决了问题,则
1.在PYTHONPATH中提到的所有路径中搜索“resource”文件夹
1.如果找到这样的文件夹,则将其重命名/重构为其他名称,例如“resources”
anhgbhbe4#
I had a similar issue on starting Jupyter Notebooks on Windows 10.
When I initially ran the regular startup script, I got a windows terminal that opened and immediately closed, too fast to see any error messages. So, I opened a windows 10 powershell terminal and ran
conda update conda and conda update --all then I ran jupyter-notebook at the windows prompt. The results were:
Traceback (most recent call last): File "E:\Users\Bob\anaconda3\Scripts\jupyter-notebook-script.py", line 6, in from notebook.notebookapp import main File "E:\Users\Bob\anaconda3\lib\site-packages\notebook\notebookapp.py", line 76, in from .base.handlers import Template404, RedirectWithParams File "E:\Users\Bob\anaconda3\lib\site-packages\notebook\base\handlers.py", line 24, in import prometheus_client File "E:\Users\Bob\anaconda3\lib\site-packages\prometheus_client_init_.py", line 3, in from . import ( File "E:\Users\Bob\anaconda3\lib\site-packages\prometheus_client\process_collector.py", line 11, in _PAGESIZE = resource.getpagesize() AttributeError: module 'resource' has no attribute 'getpagesize'
I opened process_collector.py in the site-packages\prometheus_client in notepad++ and changed line 9 import resource to import resources and line 11 _PAGESIZE = resource.getpagesize() to _PAGESIZE = resources.getpagesize()
I searched for other instances of resource and found none. I then saved the file and reran jupyter-notebook at the windows terminal prompt.
This time I got: Traceback (most recent call last): File "E:\Users\Bob\anaconda3\Scripts\jupyter-notebook-script.py", line 10, in sys.exit(main()) File "E:\Users\Bob\anaconda3\lib\site-packages\jupyter_core\application.py", line 254, in launch_instance return super(JupyterApp, cls).launch_instance(argv=argv, **kwargs) File "E:\Users\Bob\anaconda3\lib\site-packages\traitlets\config\application.py", line 844, in launch_instance app.initialize(argv) File "E:\Users\Bob\anaconda3\lib\site-packages\traitlets\config\application.py", line 87, in inner return method(app, *args, **kwargs) File "E:\Users\Bob\anaconda3\lib\site-packages\notebook\notebookapp.py", line 2126, in initialize self.init_resources() File "E:\Users\Bob\anaconda3\lib\site-packages\notebook\notebookapp.py", line 1697, in init_resources old_soft, old_hard = resource.getrlimit(resource.RLIMIT_NOFILE) AttributeError: module 'resource' has no attribute 'getrlimit'
Still having Notepad++ open, I opened notebookapp.py in site-packages\notebook and searched for resource. I found and changed the following lines: Line 37 import resource to import resources line 40 resource = None to resources = None line 1036 resource is None to resources is None line 1040 soft, hard = resource.getrlimit(resource.RLIMIT_NOFILE) to soft, hard = resources.getrlimit(resources.RLIMIT_NOFILE) line 1693 if resource is None: to if resources is None: line 1697 old_soft, old_hard = resource.getrlimit(resource.RLIMIT_NOFILE) to old_soft, old_hard = resources.getrlimit(resources.RLIMIT_NOFILE) line 1706 resource.setrlimit(resource.RLIMIT_NOFILE, (soft, hard)) to resources.setrlimit(resources.RLIMIT_NOFILE, (soft, hard))
I searched for other instances of resource and found none. I then saved the notebookapp.py file and reran jupyter-notebook at the windows terminal prompt. This time Jupyter Notebooks opened with the expected files tab displayed. I quit out of Jupyter Notebooks and restarted using the normal link to the startup script and it worked as expected.
I am not sure what caused this issue. I did not intentionally update anything before I saw the issue. Yesterday, Jupyter Notebooks worked as expected, today when I tried to run it, I got the flicker screen as described above.
f0ofjuux5#
我遇到了与您相同的错误,经过调查,我发现我错误地在运行的应用程序的根目录中创建了一个资源文件夹。