admin管理员组

文章数量:1355063

Everythink was going fine, but when I finish my code and tried to run then I got this error, what do you think what could happen. I use Linux Mint. The problem is with EEL module I think, when I run html code and go to console I can see GET file:///eel.js net::ERR_FILE_NOT_FOUND I have been solving the problem already 3-4 days, but I could not find the answer. I hope you will help me with this. Python code:

import eel
import pyowm


own = pyowm.OWM('d845c8640738fe82515cb1277bb3dd38')

eel.init('web')

eel.start('main.html', size=(700, 700))

@eel.expose
def get_weather(city):

    mgr = own.weather_manager()

    observation = mgr.weather_at_place(city)
    w = observation.weather 

    temp = w.temperature('celsius')['temp']

    return city + ' ' +  str(temp)

And html/js code:

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>Weather</title>


    <script type="text/javascript" src="/eel.js"></script>
    <link rel="stylesheet" type="image/png" href="weather-icon.png">
    <link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>

    <input id="location" type="text" placeholder="Write the name of your Country ot City" required="" value="Bukhara, Uzbekistan">

    <button id ="show">Know the weather</button>

    <div id="info">


        
    </div>
    <script src=".5.1/jquery.min.js"></script>
    <script type="text/javascript">

        async function display_weather(){
            let place = document.getElementById('location').value;

            let res = await eel.get_weather(place)();
            document.getElementById('info').innerHTML = res;
        }

        jQuery('#show').on('click', function(){
            display_weather();
        });

    </script>

</body>
</html>

Before I asked and indicated only second error whick I saw in the browser's console, unfortunately I can not find the asnwer. Thanks

Everythink was going fine, but when I finish my code and tried to run then I got this error, what do you think what could happen. I use Linux Mint. The problem is with EEL module I think, when I run html code and go to console I can see GET file:///eel.js net::ERR_FILE_NOT_FOUND I have been solving the problem already 3-4 days, but I could not find the answer. I hope you will help me with this. Python code:

import eel
import pyowm


own = pyowm.OWM('d845c8640738fe82515cb1277bb3dd38')

eel.init('web')

eel.start('main.html', size=(700, 700))

@eel.expose
def get_weather(city):

    mgr = own.weather_manager()

    observation = mgr.weather_at_place(city)
    w = observation.weather 

    temp = w.temperature('celsius')['temp']

    return city + ' ' +  str(temp)

And html/js code:

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>Weather</title>


    <script type="text/javascript" src="/eel.js"></script>
    <link rel="stylesheet" type="image/png" href="weather-icon.png">
    <link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>

    <input id="location" type="text" placeholder="Write the name of your Country ot City" required="" value="Bukhara, Uzbekistan">

    <button id ="show">Know the weather</button>

    <div id="info">


        
    </div>
    <script src="https://cdnjs.cloudflare./ajax/libs/jquery/3.5.1/jquery.min.js"></script>
    <script type="text/javascript">

        async function display_weather(){
            let place = document.getElementById('location').value;

            let res = await eel.get_weather(place)();
            document.getElementById('info').innerHTML = res;
        }

        jQuery('#show').on('click', function(){
            display_weather();
        });

    </script>

</body>
</html>

Before I asked and indicated only second error whick I saw in the browser's console, unfortunately I can not find the asnwer. Thanks

Share Improve this question asked Aug 21, 2020 at 3:18 Ali6464Ali6464 531 silver badge5 bronze badges
Add a ment  | 

3 Answers 3

Reset to default 5

I already had have the same problem and I was be able to solve. The way I've solved is just change the line:

eel.init('web')

so that it uses the absolute path, like

eel.init('C:/.../web') where 'C:/.../web' is the current location of my web folder

If you want to search more about it I remend this post: https://github./samuelhwilliams/Eel/issues/168 but change the path works to me

Just faced this issue and I' ve used this to solve in a more generic way:

import os

eel.init(f'{os.path.dirname(os.path.realpath(__file__))}/web')

Beside the solution amentioned by others, I found that I must run py code under the ./app/ folder.

本文标签: