When I install package with python and import it, I often get a missing imports message such as:
Import "fastapi" could not be resolvedPylancereportMissingImports
The imports always work perfectly fine, the fastapi example above will run a server and I can build an API without issue.
Can anyone explain why I am getting this error and how I could get rid of it?
Reinstall fastapi again separately.
pip install 'fastapi[all]'
pip install fastapi
pip install uvicorn
Related
Probably stupidly I tried to install the latest version of Python, in this case using the download from python site, but after doing that I was then getting python still running on the previous version python-3.6. I'm on OSX and was using sublime.
So I have been trying to work out how to update it to use the newest version. I've followed; https://opensource.com/article/19/5/python-3-default-mac.
All of the responses to queries now point to the python-3.9.5 version. So that's great and my runtime is using that. However after installing the requests using pip install I get the following error when running.
import requests
ModuleNotFoundError: No module named 'requests'''
[path: /Library/Frameworks/Python.framework/Versions/3.9/bin:/Library/Frameworks/Python.framework/Versions/3.6/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin]
I stumbled upon Modules are installed using pip on OSX but not found when importing which I have been trying to work through.
I have been able to run the import command successfully in terminal, however it's intermittent as I've tried again and it's broken, so I'm lost. I'm running it something trying to run the python3.6 version, which after updating I followed these instructions to remove when I have uninstalled that from my mac https://www.macupdate.com/app/mac/5880/python/uninstall.
If there is any ideas, would love some help, mainly to try and tell me what that error message is telling me.
In particular, what does this mean?
[path: /Library/Frameworks/Python.framework/Versions/3.9/bin:/Library/Frameworks/Python.framework/Versions/3.6/
I should clarify too; when I run 'pip list'
I see
requests 2.25.1
Assuming that you are not installing requests package properly, and assuming your python executable is named python:
python -m pip install requests
If however, your python executable is named something else instead, e.g. python3, replace python with that name:
python3 -m pip install requests
i am getting error ModuleNotFoundError: No module named 'flask_weasyprint'
when importing
from flask_weasyprint import HTML, render_pdf
when I set up an existing flask project. So I am trying to install flask_weasyprint using
pip install Flask-WeasyPrint
command but it gives below error. But i do not understand what is saying this error.
Yeah, seems like a bug. Try pip3 install Flask-WeasyPrint
Seem like you get this same issue
Try:
py -m pip install wheel
In future avoid post screenshots of error.
Hi
I have been following a step by step on how to make a login system with python, with flask-mysqldb. I'm trying to run the python script, but i end up getting a error message that i don't understand so much of.
from flask import Flask, render_template, request, redirect, url_for, session
from flask_mysqldb import MySQL
import MySQLdb.cursors
import re
app = flask(__name__)
When I'm trying to run the script, on the localhost page it also shows a error, I have copyed and pasted te error in pastebin. When I try to install the flask_mysqldb i get a error in my cmd. Here is what my cmd says.
I have google with parts of the error, trying to find some information about what the problem can be. And tryed to pip install a lot for things that some people have said that can work, without any luck. And can't figure out how to get this to work.
I also tryed to install Anaconda terminal to run the command in there for installing flask_mysqldb, but no luck. Tryed to uninstall and reinstall everything, but nothing changed the error i get.
The error:
ModuleNotFoundError: No module named 'flask_mysqldb'
indicates that the module has not been installed or installed in a wrong environment.
Install it using:
pip install flask-mysqldb
The stack from from the error
File "c:\users\chris\appdata\local\programs\python\python37-32\lib\site-packages\flask\cli.py", line 240, in locate_app
__import__(module_name)
File "C:\xampp\htdocs\pythonlogin\main.py", line 2, in <module>
from flask_mysqldb import MySQL
ModuleNotFoundError: No module named 'flask_mysqldb'
is indicating that Python 3.7 in involved.
In this case, using pip to install flask_mysqldb will lead to grief. Use pip3 instead. E.g.,
pip3 install flask_mysqldb
I am trying to run some code that has 'import websocket' however I am getting the error: ModuleNotFoundError: No module named 'websocket'
I have Python 3.7.3 and I am running in Spyder (if that makes a difference).
So from other questions/answers I found on here, in my cmd I ran pip install websocket and then also pip install websocket-client when the first one didn't run.
I am still getting the ModuleNotFoundError. Does it matter the location/folder of the code or where I install the pip command in cmd?
My python code starts with these import statements:
import json
import websocket
import traceback
import helper
import ssl
import time as time
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
from scipy.interpolate import griddata
from mpl_toolkits.mplot3d import Axes3D
In cmd I ran:
C:\Users\myname>pip install websocket
and also:
C:\Users\myname>pip install websocket-client
The error I am getting is:
File "C:/Users/micki/Downloads/Derbit-Volatility-Visulization-master/Derbit-Volatility-Visulization-master/Volatility Surface Class.py", line 2, in <module>
import websocket
ModuleNotFoundError: No module named 'websocket'
Not sure, as you did not cover how you installed and are using Spyder, though I think it is probably an issue with your environment. You might also find that you are missing the module "helper" as well. There's two easy options as follows:
If you installed and are using Spyder via conda or anaconda, follow their documentation on installing websocket-client to the correct environment found here.
The second option (the preferred option IMHO, as you can use any IDE or text editor going forward), regardless of how you installed Spyder, would be to create a python virtual environment python3 -m venv /path/to/new/virtual/environment, pip install all your dependencies in said environment, then link Spyder's interpreter to the interpereter that was installed when you made the environment. In Spyder, go to Tools -> Preferences -> Python interpreter -> check the "Use the following Python interpreter:" radio button and enter the path to the interpreter from the environment you just created. For reference, see docs on making and using a python venv here.
If the websocket and websocket-client doesn't work, try:
pip install websocket_client
This solved my issue:
sudo pip install websocket-client
I am currently running python 2.7.
I already installed python-pushover.
But when I try to import following code
from pushover import init, Client'
I get following error
from pushover import init, Client
ImportError: cannot import name init
I have tried
import pushover
from pushover import init, Client
same error.
My guess is that you did pip install pushover. However, this will install a different package from the one you are interested in. Instead, you will need to uninstall that package:
pip uninstall pushover
and install the correct package:
pip install python-pushover
Once you do that, your code should work as expected.