derekhe / msfs2020-google-map

Replace MSFS2020's bing map to google map
MIT License
278 stars 37 forks source link

[BUG] UnableToWriteHosts #66

Closed chaszs closed 3 years ago

chaszs commented 3 years ago

When I press run, in the last version of the app, that is what appears, It never worked for me, but now appears that:

File "G:\Flight Simulator 2020\Google no Bing\Python39\lib\site-packages\python_hosts\hosts.py", line 193, in write with open(output_file_path, mode) as hosts_file: PermissionError: [Errno 13] Permission denied: 'c:\windows\system32\drivers\etc\hosts'

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "G:\Flight Simulator 2020\Google no Bing\Python39\lib\tkinter__init.py", line 1892, in call__ return self.func(*args) File "G:\Flight Simulator 2020\Google no Bing\src\app.py", line 237, in run self.stop() File "G:\Flight Simulator 2020\Google no Bing\src\app.py", line 317, in stop restore_hosts() File "G:\Flight Simulator 2020\Google no Bing\src\runner.py", line 42, in restore_hosts hosts.write() File "G:\Flight Simulator 2020\Google no Bing\Python39\lib\site-packages\python_hosts\hosts.py", line 216, in write raise UnableToWriteHosts() python_hosts.exception.UnableToWriteHosts

HELP! I don't know what to do. My firewall is on, game is not running: in other versions I tried with and without firewall and the result is the same. Maybe hosts archive is protected?

Thanks.

derekhe commented 3 years ago

Mostly it is your antivirus's problem. Please check or disable antivirus. Some people has same issue, they just set the hosts file writable.

skipph commented 3 years ago

How about if no anti virus is running.

derekhe commented 3 years ago

https://github.com/derekhe/msfs2020-google-map/wiki/FAQ#host-related-issue

derekhe commented 3 years ago

@skipph did it fix?

houmes2 commented 3 years ago

I have a similar problem. When I press run I receive the error message "Override hosts failed". This is what I have in the CMD window.

E:\MSFS2020 addons\Scenery\msfs2020-google-map-2021-11-06_SfWil>if exist .\Python39\python.exe ( echo "Use embedded python" .\Python39\python.exe src\app.py ) else ( echo "Use user python" py -m pip install -r requirements.txt py src\app.py ) "Use embedded python" root "Důvěryhodné kořenové certifikační autority" Related Certificates:

Exact match: Element 3: Serial Number: c9dfffaa7d7e8ef1c6bc38e6781f0fb1 Issuer: CN=mkcert DESKTOP-O2CB4QF\derekhe@DESKTOP-O2CB4QF, OU=DESKTOP-O2CB4QF\derekhe@DESKTOP-O2CB4QF, O=mkcert development CA NotBefore: 18.08.2021 15:01 NotAfter: 18.11.2023 15:01 Subject: OU=DESKTOP-O2CB4QF\derekhe@DESKTOP-O2CB4QF, O=mkcert development certificate Non-root Certificate Cert Hash(sha1): ae4cfdbea30eaa635443b6914b3b863b52f693de

Certificate "DESKTOP-O2CB4QF\derekhe@DESKTOP-O2CB4QF" already in store. CertUtil: -addstore command completed successfully.

I have turned off the firewall and antivirus, made the hosts file writable and nothing helps. The hosts file itself is in original condition without any other entries (you can check). hosts.txt I cannot even delete it as the system says that the file is being used by other process (System). The simulator itself is running ok. Do you have any ideas what to do?

derekhe commented 3 years ago

Yes, if you can’t even delete the file which means the hosts file are “protected” by something. If you can’t delete or change it, then the mod can do nothing. So please find out if something locked your hosts file. Some antivirus has settings that set the “hosts” file protected.

houmes2 commented 3 years ago

I have solved my hosts problem successfully. I am using ZoneAlarm antivirus + firewall and if you are having the same problem you have to untick the line "lock hosts files" in firewall advanced settings . My problem was that if I shut down ZoneAlarm completely, this function remained active. I hope this helps someone in the future. After that, the utility worked fine.

zonealarm

derekhe commented 3 years ago

Thanks for feedback. Normally it is similar issue. I will close this now.

Xpress690 commented 2 years ago

I have no trouble changing or deleting the hosts file. I can edit and do everything with it..