Visual Studio Code ModuleNotFoundError: No module named '_overlapped' - python

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.

Related

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.

For what reason would a Flask application run fine, but fail to load a module in the unittest?

So, I created a small flask API. Basically a wrapper for another API.
I used requests-futures to send multiple calls asynchronously.
I set up my virtual environment. Everything works exactly as I intend. However, when I try to run some tests I've written (using python -m unittest) this is the error I get:
======================================================================
ERROR: test (unittest.loader._FailedTest)
----------------------------------------------------------------------
ImportError: Failed to import test module: test
Traceback (most recent call last):
File "/usr/lib/python3.8/unittest/loader.py", line 436, in _find_test_path
module = self._get_module_from_name(name)
File "/usr/lib/python3.8/unittest/loader.py", line 377, in _get_module_from_name
__import__(name)
File "/home/cwverica/take-home-apps/quixr/test.py", line 2, in <module>
from app import app, session
File "/home/cwverica/take-home-apps/quixr/app.py", line 3, in <module>
from requests_futures.sessions import FuturesSession
ModuleNotFoundError: No module named 'requests_futures'
I have reinstalled the module using pip. I made sure to pip freeze > requirements.txt just in case it was reading module availability from there. But all in all I'm stumped. If anyone could help me out here, I'd greatly appreciate it.

Pyp3 gives ModuleNotFoundError even if packaged is install

So I'm trying to figure out if I can speed up my code. For that purpose I installed pyp3. But when I try to run the python file using pyp3 I get error in the first line itself ModuleNotFoundError, But when I use simple python my code works smoothly. Is it due to python version difference ? I'm new to pyp3. Any suggestion/help would be appreciated. Thankyou
pypy3 main_feature_extraction.py
Traceback (most recent call last):
File "main_feature_extraction.py", line 1, in <module>
from dotenv import find_dotenv, load_dotenv
ModuleNotFoundError: No module named 'dotenv'

Python unittest fails to load modules when executed from command line

When I try to run python unittest from command line, in windows, I get the following error:
test_validateXml (unittest.loader.ModuleImportFailure) ... ERROR
consequently in the details there is an error message that reads:
Traceback (most recent call last):
File "C:\Python27\lib\unittest\loader.py", line 254, in _find_tests
module = self._get_module_from_name(name)
File "C:\Python27\lib\unittest\loader.py", line 232, in _get_module_from_name
__import__(name)
from application.helpers.fileHelper import FileIO as fileIO
ImportError: No module named application.helpers.fileHelper
The command I'm running is:
python -m unittest discover -v -p "*est*.py"
As I understand the reading I've done, all that's required in order to import modules is an __init__.py file in every directory of the project, which I have.
When I run the test from Visual Studio they run without any problems, any help is appreciated thanks.

Error "ImportError: no module named mux" in Python

I installed a module one month ago. At that time, I could import the module successfully.
Now, when I import this module, there is an ImportError,
>>> import anuga
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/lili/anuga_core/source/anuga/__init__.py", line 110, in <module> from anuga.file_conversion.urs2nc import urs2nc
File "/home/lili/anuga_core/source/anuga/file_conversion/urs2nc.py", line 12, in <module>
from mux import WAVEHEIGHT_MUX_LABEL, EAST_VELOCITY_LABEL, \
ImportError: No module named mux
How could I solve this problem?
ImportError comes only when the module is not available in the list called sys.path. Since the current operating system is Linux based (I got an idea from the error message /home/lili), it is required to have mux.py in the path (i.e, sys.path). The mux.py file will be exactly similar to the file available in this link.
`https://anuga.anu.edu.au/svn/anuga/trunk/anuga_core/source/anuga/file/mux.py`
All these problems come when the installation of ANUGA is not proper.

Categories

Resources