I recently cloned a code from Gitlab on my PC and I'm getting this error
ModuleNotFoundError: No module named 'models'
At this line
from models import *
The file that contains this line is in a directory called interfaces at the same level with models.
---apps
---interfaces
test.py
---models
My colleagues cloned the code and they didn't have this problem. What is going on my side?
I am using Python 3.6.8 and Pycharm 2022.1.4 (Community Edition) and it's a Flask project.
Edit: when I do this, the error disappears:
from app.models import *
The problem was with my Pycharm. I had to right click on the "app" folder and mark it as Sources Root
Related
I am trying to run fbprophet and streamlit based web app on crypto-prediction, but the streamlit app does not recognize the prophet module
This is the error
ModuleNotFoundError: No module named 'prophet'
Traceback:
File "C:\Users\HP\AppData\Local\Programs\Python\Python311\Lib\site-packages\streamlit\runtime\scriptrunner\script_runner.py", line 565, in _run_script
exec(code, module.__dict__)
File "E:\Shubham\CPP Final Year Project\finadict-main\app.py", line 6, in <module>
from prophet import Prophet
I have installed anaconda as it is easier to run fbprophet in anaconda
I have also created the environment named prophet39
enter image description here
While running the streamlit application this error comes
enter image description here
What should i do now
I have visited all possible solution on internet and cannot find any solution to this!!
this is the code code
I am using windows by the way
I have tried all possible solution on the internet but not able to run this streamlit app
Looks like you also shared this on our forum – posting the solution here for visibility
You have the wrong (outdated) package in your requirements.txt file.
The latest package name should be prophet . And btw. remove the pystan
package. And then change also the import name in you app.py file.
Can I access the class inside the multiple folder of one script file in python I did that and when I start running the scripts it is working fine here(import like this from tosca_o.service.service_model.service_model_service import ServiceModelService) in eclipse, but when I start run in the ubuntu terminal I m facing some issues the issue is below.
Issue
ImportError while loading conftest '/home/naga/workarea/tosca-o/zyuvnag/tosca-o/core/rest/src/tosca_o/rest/tests/conftest.py'.
conftest.py:4: in
from tosca_o.service.service_model.service_model_service import ServiceModelService
E ModuleNotFoundError: No module named 'tosca_o'
Could please help me to resolve this issue.
Thanks for your support.
when I start running the scripts it is working fine here(import like this from tosca_o.service.service_model.service_model_service import ServiceModelService)in the eclipse.
but when I start run in the ubuntu terminal I m facing some issues the issue is below.
Issue
ImportError while loading conftest '/home/naga/workarea/tosca-o/zyuvnag/tosca-o/core/rest/src/tosca_o/rest/tests/conftest.py'.
conftest.py:4: in
from tosca_o.service.service_model.service_model_service import ServiceModelService
E ModuleNotFoundError: No module named 'tosca_o'
I followed the instructions and successfully installed pypostal python package (package to help parse addresses) https://github.com/openvenues/pypostal.
I'm trying to set this up so the python script can be callable through an apache server on an ubuntu box. It works fine when executing the script from Terminal. However, it doesn't work when I make a call to apache to execute the script and I get the following error in the apache logs. I believe it might be some pathing issue but I haven't had much luck to resolve it. Any ideas will be appreciated.
Error:
File "/var/www/html/cgi-bin/get_parsedAddress.py", line 5, in
from postal.parser import parse_address
ModuleNotFoundError: No module named 'postal'
python script contents:
import sys
from postal.parser import parse_address
addressList = parse_address(sys.argv[1])
print(addressList)
I'm in battle with one error sine yesterday. I checked similar topics on stackoverflow, but nothing worked.
That's my project structure:
When I type:
uvicorn main:app --reload
To start fastapi this error occure:
File ".\main.py", line 2, in
from scraper.scraper import Scraper
File ".\scraper\scraper.py", line 3, in
import pandas as pd
ModuleNotFoundError: No module named 'pandas'
I have tried to add new PATH in windows, change structure of my project. Do you know hot to handle it?
Not pycharm problem,
when running in pycharm terminal your python runs in venv - which has seperate pip packages (thats the point of venv), but uvicorn probably passes the data to local python installation and not the venv.
so now after installing pandas in regular cmd, its installed system wide, and you can try running your command in pycharm too
My Flask Application is crashing when I'm trying to access it.
This is similar error to this or this. However, my set-up seems correct.
flask.cli.NoAppException: The file/path provided (server) does not appear to exist. Please verify the path is correct. If app is not on PYTHONPATH, ensure the extension is .py
My environment variable correctly set.
export FLASK_APP=server.py
export FLASK_DEBUG=1
My server file is server.py, and I don't have any __init__.py in the directory.
I don't recall having change anything special in the code. Where does the bug could come from?
The issue was that some package were missing or corrupted.
I reinstalled everything with pip3 install -r requirements.txt --ignore-installed and now it works fine.
This error may be a sign that an import is not found.
To see which import is missing, try to run your server.py file with the python interpreter:
python yourapp.py
Example of output :
Traceback (most recent call last):
File "yourapp.py", line 4, in <module>
from flask_httpauth import HTTPBasicAuth
ImportError: No module named flask_httpauth
Source (and other leads)
For me, solution was fixing a misspelled function name "create_app" in my _ init _.py
from flask import Flask
def create_app(test_config=None):
app = Flask(__name__)
return app
Super late answer, but I just ran into this and the solution was to use a Remote WSL connection in VS Code. I thought I was in the correct folder, but VS Code was looking at a very similar folder in Windows. You can tell you're in the wrong folder by running "touch somefile.abc" in your linux terminal, from the project folder, but that file doesn't automatically appear in VS Code's folder structure.
https://code.visualstudio.com/docs/setup/linux
https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-wsl