jneilliii / OctoPrint-WindowsInstaller

77 stars 21 forks source link

PermissionError: [WinError 5] Access is denied #16

Closed kocane closed 1 year ago

kocane commented 1 year ago

I'm sorry if this doesn't really belong in here but I can't for the life of me get the service to start.

The log gives me the following:

2023-09-10 23:07:03,068 - octoprint.startup - INFO - ******************************************************************************
2023-09-10 23:07:03,070 - octoprint.startup - INFO - Starting OctoPrint 1.9.1
2023-09-10 23:07:03,070 - octoprint.startup - INFO - ******************************************************************************
2023-09-10 23:07:03,085 - octoprint.util.connectivity.connectivity_checker - INFO - Connectivity state is currently: online
2023-09-10 23:07:03,085 - octoprint.util.connectivity.connectivity_checker - INFO - Connecting to 1.1.1.1:53 is working
2023-09-10 23:07:03,085 - octoprint.util.connectivity.connectivity_checker - INFO - Resolving octoprint.org is working
2023-09-10 23:07:03,091 - octoprint.plugin.core - INFO - Loading plugins from C:\OctoPrint\WPy64-31050\python-3.10.5.amd64\Lib\site-packages\octoprint\plugins, C:\OctoPrint\basedir\5000\plugins and installed plugin packages...
2023-09-10 23:07:06,058 - octoprint.plugin.core - INFO - Plugin Pi Support Plugin (2023.5.24) did not pass check, not loading.
2023-09-10 23:07:06,176 - octoprint.plugin.core - INFO - Found 18 plugin(s) providing 18 mixin implementations, 34 hook handlers
2023-09-10 23:07:06,245 - octoprint.server.heartbeat - INFO - Starting server heartbeat, 900.0s interval
2023-09-10 23:07:06,246 - octoprint.cli.server - ERROR - Uncaught exception
Traceback (most recent call last):
  File "C:\OctoPrint\WPy64-31050\python-3.10.5.amd64\lib\runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "C:\OctoPrint\WPy64-31050\python-3.10.5.amd64\lib\runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "C:\OctoPrint\WPy64-31050\python-3.10.5.amd64\lib\site-packages\octoprint\__main__.py", line 6, in <module>
    octoprint.main()
  File "C:\OctoPrint\WPy64-31050\python-3.10.5.amd64\lib\site-packages\octoprint\__init__.py", line 1008, in main
    octo(args=args, prog_name="octoprint", auto_envvar_prefix="OCTOPRINT")
  File "C:\OctoPrint\WPy64-31050\python-3.10.5.amd64\lib\site-packages\click\core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
  File "C:\OctoPrint\WPy64-31050\python-3.10.5.amd64\lib\site-packages\click\core.py", line 1055, in main
    rv = self.invoke(ctx)
  File "C:\OctoPrint\WPy64-31050\python-3.10.5.amd64\lib\site-packages\click\core.py", line 1657, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "C:\OctoPrint\WPy64-31050\python-3.10.5.amd64\lib\site-packages\click\core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "C:\OctoPrint\WPy64-31050\python-3.10.5.amd64\lib\site-packages\click\core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File "C:\OctoPrint\WPy64-31050\python-3.10.5.amd64\lib\site-packages\click\decorators.py", line 26, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "C:\OctoPrint\WPy64-31050\python-3.10.5.amd64\lib\site-packages\octoprint\cli\server.py", line 317, in serve_command
    run_server(
  File "C:\OctoPrint\WPy64-31050\python-3.10.5.amd64\lib\site-packages\octoprint\cli\server.py", line 163, in run_server
    octoprint_server.run()
  File "C:\OctoPrint\WPy64-31050\python-3.10.5.amd64\lib\site-packages\octoprint\server\__init__.py", line 378, in run
    self._setup_mimetypes()
  File "C:\OctoPrint\WPy64-31050\python-3.10.5.amd64\lib\site-packages\octoprint\server\__init__.py", line 2093, in _setup_mimetypes
    mimetypes.add_type("application/javascript", ".js")
  File "C:\OctoPrint\WPy64-31050\python-3.10.5.amd64\lib\mimetypes.py", line 356, in add_type
    init()
  File "C:\OctoPrint\WPy64-31050\python-3.10.5.amd64\lib\mimetypes.py", line 368, in init
    db.read_windows_registry()
  File "C:\OctoPrint\WPy64-31050\python-3.10.5.amd64\lib\mimetypes.py", line 253, in read_windows_registry
    _mimetypes_read_windows_registry(add_type)
PermissionError: [WinError 5] Access is denied

I've of course tried to reinstall it, where I also cleared out anything Python related I could fine, but to no avail. I've tried making Python.exe run as administator always but it obviously didn't change anything, since the service is running as system as it is.

I'm running Windows 10 LTSC x64.

jneilliii commented 1 year ago

The only thing I can tell from the error is that it's permissions related with the registry. I've never seen this before, so might suspect some form of virus protection maybe preventing the access.

kocane commented 1 year ago

@jneilliii fair enough, maybe my Windows install is just botched. I've disabled Defender completely so there's not even that. I really don't know. Is the function nessesary or could it essentially be commented out, do you know?

jneilliii commented 1 year ago

Not completely sure, but seems to be related to mimetypes which are important/necessary for serving the files properly. When you reinstalled, did you delete the C:\OctoPrint folder completely?

jneilliii commented 1 year ago

Just curious, if you open services app in windows and find OctoPrint on Port 5000 does it list the "Log On As" as local system like this?

image

kocane commented 1 year ago

Yep, its set to log on as system.

I fixed it by commenting out line 253 and 254 in mimetypes.py as per the suggestion here. Now it starts just fine. I haven't configured anything yet so I'm unsure if it will cause any weird issues but service starts and webui is accessible.

I've honestly no idea what would be causing this but I'm fairly sure it's some anomaly on my PC and as worst an issue with Python and not your installer. I also had trouble getting OctoPrint/Python to work with the manual installation process, but looks like there's finally luck with it by using your installer, so thank you so much for making it!