My import statements are as follows:
from flask_wtf import FlaskForm
from wtforms import StringField, PasswordField, BooleanField, SubmitField
from wtforms.validators import DataRequired
I am able to execute the file - blank.py - within Pycharm and do not receive a ModuleNotFoundError.
Whenever I execute flask run in terminal I get ModuleNotFoundError: 'flask_wtf' and it traces back to 'blank.py'.
I am not sure why this is happening as I have both flask and flask-wtf installed globally and locally. I have never had this problem when working with other libraries.
How do I fix this? Thank you for you help.
Related
i installed flask in the cmd using the pip install flask command and i also tested it in the cmd and it works.
But when i go to pycharm all the modules i download using pip are for some reason in lib/site_packages
instead of just being in site_packages.the lib folder
and then i do "from flask import Flask"
and it says that " cannot import name 'Flask' from 'flask' (C:\Users\User\PycharmProjects\pythonProject1\flask.py)"
the error
there is no Flask in flask
Change the py file name to anything else. naming your flask file as flask.py will create a namespace conflict.
So i wrote a little programm in python with use of tkinter. The repo is found here: https://github.com/Odatas/MeisterTools
I now want to create an exe so people only need to use the exe when they want to use the program. But the exe i create with pyinstaller doesnt work and throws the error:
Import Error: cannot import name 'travel' from 'main'
The cmd i opend to creat the exe is directly out of anaconda envoirment.
I cd into the folder where all the scripts are and then run it like this:
pyinstaller --onefile patrickstools2.py
I even tried to make every import an hidden import:
pyinstaller --onefile --hidden-import=init --hidden-import=main --hidden-import=checker --hidden-import=contact --hidden-import=dangers --hidden-import=droptable --hidden-import=importexcel --hidden-import=odatasfunctions --hidden-import=randomenpc --hidden-import=scrolltest --hidden-import=sonstiges --hidden-import=travel patrickstools2.py
that doesnt help either. I added the path through Anaconda to the PYTHONPATH variable...so it should be know in any way shape or form.
The complet code is in Anaconda. The Error gets thrown in the import section of the main file:
# page classes import
import os
try:
import Tkinter as tk
except ImportError:
import tkinter as tk
try:
import ttk
py3 = False
except ImportError:
import tkinter.ttk as ttk
py3 = True
# page classes import
from . import travel
from . import contact
from . import dangers
from . import sonstiges
from . import randomenpc
I allready created an exe with pyinstaller from a previous version. But i made some changes to the structure of the programm. The run.py is only there because i work with spyder and as far as i know spyder needs it because else the import doesnt work correctly.
I created an SQLite3 database, called page.db.
I am trying to use it in python.
from flask import Flask
from flask_sqlalchemy import SQLAlchemy
import sqlite3
app=Flask(__name__)
app.config['SQLALCHEMY_DATABASE_URI']="sqlite:////mnt/home/cc/page.db'
db=SQLAlchemy(app)
class tabb(db.Model):
name=db.Column(db.Username,primary_key=True)
After writing this code, I enter python shell and run the command from main import db. It shows an error saying:
ModuleNotFoundError: No module named 'main'
How can I fix this?
Are you sure the filname is main and that you are in the same directory as main.py when opening the python interpreter?
open terminal and then cd (projectname), after try again
I have an issue with Python 3.6.3 on Windows 10.
I have installed flask_bootstrap. Here is my (edited) pip freeze:
C:\Users\pablo\willwriter2>pip freeze
Flask==0.12.2
Flask-Bootstrap==3.3.7.1
When I run a very simple script:
from flask import Flask
from bootstrap import Bootstrap
app = Flask(__name__)
bootstrap = Bootstrap(app)
#app.routes('/')
def homepage():
return "<h1>Hello World</h1>"
I get the following error message:
File "C:\Users\pablo\willwriter2\main2.py", line 2, in <module>
from bootstrap import Bootstrap
ModuleNotFoundError: No module named 'bootstrap'
This error occurs whether I use a virtual environment or the global python install. It has occurred for other modules as well.
Does anyone know why this is happening?
Thanks,
Paul.
When I import winsound and then try to run the program, it returns an error message saying:
ImportError: No module named 'winsound'.
Are there any settings I need to change?
winsound only exists in Python installed under Windows. Do not attempt to import it if you are not running under Windows.