ImportError: cannot import name 'Page' - python

I have written a game in an Otree Project, but every time i want to clean my database or start the server, this message appears. It only happens with my game, but not when an example game is using that command.

Look in your app for the folder _builtin. There should be a file __init__.py that has the same contents as every other app's _builtin/__init__.py. If not, copy it from the other app.

Related

import a file in a folder python

I want to import a file from a folder in my replit discord.py project. I’m using the same project to do a website , with flask. This is the structure
project ——|—— main.py
|
|—— static ——|—— Templates —— index.html
|
|—— flask_.py
I’m using a function who keep alive the bot using uptime robot. Before, I didn’t need a website. The flask app just print in a website output I’m alive. But now, I want to create a full website with flask using HTML. The HTML isn’t a problem. The problem is that, in the structure, you can see that flask_.py is in the folder static and the main.py file isn’t. Because the function to keep alive the bot is in flask_.py, I can’t import it like that from flask_ import keep_alive. I don’t know how to import it. Can you help me?
You need to start from the root directory of the project:
from static.flask_ import keep_alive
But why do you have have dynamic code in a folder named static? I suggest moving the flask_.py folder to the root of the project then you can use the import you already have.
Side note: in python, we typically use underscores to separate words in names. Ending a filename with an underscore is unusual.

How to integrate a python file onto a Django project?

I am trying to include a machine learning component in my Django project. I have the method written in python. How do I get to make it work on the website using Django. Can I simply drag the ".py" file into the file structure and call it from an HTML page? I am new to Django any help would be greatly appreciated.
Yes you can directly copy file into your Django Directory structure. Let's say you have a file test.py and a function written in it as def print(). And you have copied the file in app directory. Then you can call it in views.py as from app.test import print. print function will be imported in views.py and you can use it to serve in html as you want.

How should I manage url versioning in Django

I have a doubt about the optimal structure of my files.
Right now, I have all my urls in a file api.py.
The endpoints for a new version of the app are being located in a new api_v2.py file, only the urls that require a new version, is that ok?
Also, if a new functionality is added to the app, should I put the new urls directly on api_v2.py? or maybe on the base api.py and keep the api_v2.py for the urls that have a "new version" of themselves?
Any advice will help.

Updater for Python Application

I'm currently developing a small tool that's supposed to let players of a particular game customize their game way quicker thn actually browsing through the game files, making changes to each and any .ini file. However that is not the matter.
I'd like to get a function going to update my application within itself where there i have a function to download a .zip with the most recent version of my application and unzip it onto the app's directory.
However i need some sort of checkig mechanism to determine rather there's a new version of my app or not. As for that matter, i've uploaded both a .html aswell as a .txt with just a 0 in it which would then be changed to a 1 and uploaded to the web server in case there's an update.
So my question is how you'd go through this as in how would you read the text of the .txt file for example and determine rather it's 0 or 1 in so if the result is 1, it'll go over to downloading the newest version.
Any input is welcome,
Best regards,

writing my first Trac macro

Ok, I've looked all over, and I think I'm doing this right, but I'm not getting any results. Is there anyone out there who's written Trac macros that can guide me through the first steps? Here's what I've written:
from trac.wiki.macros import WikiMacroBase
from genshi.builder import tag
class MyMacro(WikiMacroBase):
"""Proof of concept"""
revision = "$Rev$"
url = "$URL$"
def expand_macro(self, formatter, name, args):
return tag.b("Hello world.")
I've saved it as a .py file and put it in my Trac project's /plugins directory. Do I need to restart apache? Am I correct in expecting [[MyMacro]] to output a Hello world. on the page?
When creating macros using that format, Trac expects your class to be named "<name>Macro". For example, if you wanted a macro named JustASample, you would name the class JustASampleMacro. Since you named your class MyMacro, Trac thinks that you want your macro to be named My. Try using [[My]] on a wiki page and see if you get the output you're expecting.
After you copy the file into the plugins directory, you will indeed want to restart the web server. Before doing so, delete any .pyc files that were created for your plugin. Also, ensure that the file is readable by the account under which the web server runs.

Categories

Resources