Flask - ModuleNotFoundError, though it is in the same folder - Updated - python

everyone. Can't understand where my problem is.
My structure is:
But in my cmd I have:
(venv2) C:\Users\chainsaw\Desktop\work\bot-1\archie\autosales_bot>flask run
* Environment: production
WARNING: This is a development server. Do not use it in a production deployme
nt.
Use a production WSGI server instead.
* Debug mode: off
Usage: flask run [OPTIONS]
Error: While importing "autosales_bot.wsgi", an ImportError was raised:
Traceback (most recent call last):
File "c:\users\chainsaw\appdata\local\programs\python\python37-32\lib\site-pac
kages\flask\cli.py", line 240, in locate_app
__import__(module_name)
File "C:\Users\chainsaw\Desktop\work\bot-1\archie\autosales_bot\__init__.py",
line 1, in <module>
from admin_panel.run import generate_password
ModuleNotFoundError: No module named 'admin_panel'
Thanks in advance
Maybe I should run it as
python run.py
?
I have init.py in my apps

Related

Visual Studio Code ModuleNotFoundError: No module named '_overlapped'

I have developed the following message when running flask. I attempted to add overlapped, via pip install overlap. I can't find answers to this. This is my terminal output. Can someone please help?
dvdjms#DESKTOP-OPG4GRH:/mnt/c/Users/dvdjm/Documents/CS50/project$ flask run
Usage: flask run [OPTIONS]
Try 'flask run --help' for help.
Error: While importing 'app', an ImportError was raised:
Traceback (most recent call last):
File "/home/dvdjms/.local/lib/python3.8/site-packages/flask/cli.py", line 218, in locate_app
__import__(module_name)
File "/mnt/c/Users/dvdjm/Documents/CS50/project/app.py", line 1, in <module>
from asyncio.windows_events import NULL
File "/usr/lib/python3.8/asyncio/windows_events.py", line 3, in <module>
import _overlapped
ModuleNotFoundError: No module named '_overlapped'
Did you mean to import NULL from asyncio.windows_event? I'm guessing it was automatically imported by your IDE, None is likely what you're looking for instead of NULL, which isn't a keyword in Python.

error when running flask - no module with name '_crypt'

i have a problem running flask. It started fine until I loaded a simple login form.
when running flask via gitbash, I get an error like this
flask run
* Environment: production
WARNING: This is a development server. Do not use it in a production deployment.
Use a production WSGI server instead.
* Debug mode: off
Usage: flask run [OPTIONS]
Try 'flask run --help' for help.
Error: While importing 'app', an ImportError was raised:
Traceback (most recent call last):
File "C:\Users\****\AppData\Local\Programs\Python\Python39\lib\crypt.py", line 6, in <module>
import _crypt
ModuleNotFoundError: No module named '_crypt'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\****\AppData\Local\Programs\Python\Python39\lib\site-packages\flask\cli.py", line 234, in locate_app
__import__(module_name)
File "E:\Program Files\xampp\htdocs\****\app.py", line 2, in <module>
from crypt import methods
File "C:\Users\****\AppData\Local\Programs\Python\Python39\lib\crypt.py", line 9, in <module>
raise ImportError("The crypt module is not supported on Windows")
ImportError: The crypt module is not supported on Windows
btw, i used windows
remove this from the top of the file:
from crypt import methods
it should work again. At least it did for me. VSCode may have autogenerated this for you.
This thing occur most times with auto-import in vs code.
If you inspect your code critically, you'd notice that your vs-code editor has automatically included the line of code from crypt import methods above your imports.
Just comment or delete it out and try re-running your app again, you'd be in good shape.

Start flask app from console - ModuleNotFoundError

Why, when I try to run a flask application from the console, I encounter an error: ModuleNotFoundError:
$ python run.py
Traceback (most recent call last):
File "run.py", line 1, in <module>
from src.app.controller import app
ModuleNotFoundError: No module named 'src'
or
$ env FLASK_APP=run.py flask run
* Serving Flask app "run.py"
* Environment: production
WARNING: This is a development server. Do not use it in a production deployment.
Use a production WSGI server instead.
* Debug mode: off
Usage: flask run [OPTIONS]
Error: While importing "run", an ImportError was raised:
Traceback (most recent call last):
File "/home/pronect/PycharmProjects/it-informer-master/venv/lib/python3.7/site-packages/flask/cli.py", line 240, in locate_app
__import__(module_name)
File "/home/pronect/PycharmProjects/it-informer-master/src/run.py", line 1, in <module>
from src.app.controller import app
ModuleNotFoundError: No module named 'src'
Here is a project screenshot:
But if I run the application from Paycharm, then everything works fine.
How to solve this problem?
Just try to change the code to this:
from app.controller import app
from config import Config
The file run.py is already in the directory src. The error occurs, because there is no other folder called src in the directory where the file run.py is stored.

How to run django test on google cloud platform

i'm deploying my app on Google Cloud platform. Every thing seems to be set up correctly but when i try to launch test, i get this error :
======================================================================
ERROR: purbeurre.core (unittest.loader._FailedTest)
----------------------------------------------------------------------
ImportError: Failed to import test module: purbeurre.core
Traceback (most recent call last):
File "/usr/lib/python3.6/unittest/loader.py", line 462, in _find_test_path
package = self._get_module_from_name(name)
File "/usr/lib/python3.6/unittest/loader.py", line 369, in _get_module_from_name
__import__(name)
ModuleNotFoundError: No module named 'purbeurre.core'
Is there a special setting to have all my test modules loaded ?
i did check locally and it's working on my dev environnement
It appear that i have an init.py file at root level of my project and it's messing up with unittest.
After deleting this init.py file the test is launched properly

Heroku Moduke Not Found Error

[![][1]][1]
the module 'pyicloud' is listed in requirements.txt
I have checked using the 'ls' command- I checked the directory in which the package should be - and the package does exist on the heroku server.
The app gives no such issues on my local machine, even though there is no difference in the code
I also tried the suggestions given here : https://help.heroku.com/BWJ7QYTF/why-am-i-seeing-importerror-no-module-named-site-when-deploying-a-python-app
but it didnt work.
(venv)dhcp-10-4-0-197:mes-amis mananhora$ heroku run python manage.py db upgrade -a mesamis
▸ heroku-cli: update available from 6.16.18-62346b1 to 6.99.0-ec9edad
Running python manage.py db upgrade on ⬢ mesamis... up, run.1121 (Free)
Traceback (most recent call last):
File "manage.py", line 5, in <module>
from project import app, db
File "/app/project/__init__.py", line 40, in <module>
from project.import_data.functions import import_data_blueprint
File "/app/project/import_data/functions.py", line 6, in <module>
from pyicloud import PyiCloudService
ModuleNotFoundError: No module named 'pyicloud'

Categories

Resources