I'm new to azure so excuse my lack of knowledge about the platform. I'm currently trying to run and deploy an azure function using python. these modules are currently found in my requirements.txt file
azure-functions
graphqlclient
requests
gql
asyncio
aiohttp
I run the following command pip install -r requirements.txt to install them, but for some reason, some modules cannot be found. for example the json module. import json works fine with any other python program. but when i try and add it to the requirements.txt file and run this command pip install -r requirements.txt i get the following error
ERROR: Could not find a version that satisfies the requirement json (from versions: none)
ERROR: No matching distribution found for json
i tried adding a version, but that did not solve my issue. thats only half my problem, i decided to ignore this problem for now and try to work with the modules that are working properly in the .txt file. moving on to my __init__.py file which is a timer trigger i have the following imports
import datetime
import logging
from graphqlclient import GraphQLClient
import requests
import asyncio
from gql import gql, Client
from gql.transport.aiohttp import AIOHTTPTransport
import azure.functions as func
but when i try and run my function i get the following error
Exception: ModuleNotFoundError: No module named 'gql.transport.aiohttp'
Can someone please explain these module erros? all these modules work fine when i run them from any other python program, so the problem seems to be from azure.
Thanks
I run the following command pip install -r requirements.txt to install them, but for some reason, some modules cannot be found. for example the json module.
Json is a standard library in python there's no need to install it.
Just include it in your python script as the following:
import json
Exception: ModuleNotFoundError: No module named 'gql.transport.aiohttp'
According to my test results, the default version of gql installed using the pip install -r requirements.txt command is 2.0.0.
If you use from gql.transport.aiohttp import AIOHTTPTransport to import AIOHTTPTransport, you need to install 3.x.x.
So this error is caused by version incompatibility.
Solution:
Please install the 3.x.x version of gql, you can uninstall the installed gql first, and then reinstall the new version of gql:
pip uninstall gql
pip install gql==3.0.0a5
I did some tests and the function can run normally.
Related
I am getting the following error when I try to run the backend of my web application: ImportError: cannot import name 'run_with_reloader' from 'werkzeug.serving'. It is coming from within the \lib\site-packages\werkzeug\serving.py file. I think it has to do with the line from flask_socketio import SocketIO inside my server file. Any ideas?
This error has been addressed, so you are very likely using an old version of Flask-SocketIO. Once you upgrade the error should go away.
I needed to keep using flask-socketio v4 (for older socketio.js) and pinning to 2.0.x version of Werkzeug fixed this problem
--- a/python-flask-socketio-server/requirements.txt
+++ b/python-flask-socketio-server/requirements.txt
## -1,4 +1,5 ##
flask
+Werkzeug==2.0.1
flask-socketio==4.3.2
# wheel should not be needed, but avoids pyyaml paho-mqtt bdist_wheel error
wheel
Note: I also needed to tell pip to not use cached packages, or else it would still pull in problematic 2.1.x version to virtualenv that was being regenerated.
pip install --no-cache-dir -r requirements.txt
Solution is to install the following Werkzeug version (Werkzeug-0.10.2.dev0dev-20220510) along with the following versions: [Tested in MacOS]
pip3 install Flask-SocketIO==4.3.1
pip3 install python-engineio==3.13.2
pip3 install python-socketio==4.6.0
pip3 install git+https://github.com/untitaker/werkzeug.git#reloader-perf
I had to downgrade Werkzeug and Flask to avoid this error. When Flask-SocketIO is involved, you may need to stick with older versions to avoid incompatibility issues with newer versions of Flask.
The combination that works for me is:
Flask-SocketIO==4.3.1
python-engineio==3.13.2
python-socketio==4.6.0
Flask==2.0.3
Werkzeug==2.0.3
My Flask Application was working alright and all of a sudden I am seeing this error when I run the command to launch the App locally.
File "/Flask_Trial_App2/index.py", line 6, in <module>
import pandas as pd
File "/Flask_Trial_App/virt/lib/python3.8/site-packages/pandas/__init__.py", line 16, in <module>
raise ImportError(
ImportError: Unable to import required dependencies:
numpy:
IMPORTANT: PLEASE READ THIS FOR ADVICE ON HOW TO SOLVE THIS ISSUE!
Importing the numpy C-extensions failed. This error can happen for
many reasons, often due to issues with your setup or how NumPy was
installed.
We have compiled some common reasons and troubleshooting tips at:
https://numpy.org/devdocs/user/troubleshooting-importerror.html
Please note and check the following:
* The Python version is: Python3.8 from "/Flask_Trial_App/virt/bin/python"
* The NumPy version is: "1.21.1"
and make sure that they are the versions you expect.
Please carefully study the documentation linked above for further help.
Original error was: No module named 'numpy.core._multiarray_umath'
I tried upgrading pandas and numpy, but it didn't fix the issue.
pip install --upgrade numpy
pip install --upgrade pandas
I've had similar issues to this when deploying flask apps on servers with different environments, here is something I've done that worked in the past in case this helps:
Uninstall the package then reinstall specific version using the absolute path to the python executable.
/Flask_Trial_App/virt/bin/python3 -m pip uninstall numpy; /Flask_Trial_App/virt/bin/python3 -m pip install numpy==1.21.1
Hope that may help.
The code :
import pyfiglet
print(dir(pyfiglet))
The error :
ModuleNotFoundError: No module named 'pyfiglet'
Even though I downloaded "pip 21.0.1" and imported it, it does the same thing to "termcolor" package.
sorry i install pip and the command
pip install pifiglet
report this results
equirement already satisfied: pyfiglet in /usr/local/lib/python3.9/dist-packages (0.8.post1)
but if i do the original command i have this response
from pyfiglet import figlet_format
ImportError: cannot import name 'figlet_format' from 'pyfiglet' (/usr/local/lib/python3.9/dist-packages/pyfiglet/init.py)
but in this path there is the file...
Before you can import a library, it needs to already be on your drive. You are importing it into your file. In order to get it onto your drive in the first place, you have to install it.
From the command prompt, type:
pip install pifiglet
Once you've done that, you should be able to import it.
Sorry that I have no idea how to describe this situation. The bigger package I like to install is "finance" (http://pydoc.net/finance/0.2502/finance.bankdate/). I downloaded it and unzipped to install using python setup.py install.
However, I cannot resolve importing another sub-module
bankdate(.py)
When I use finance module, there comes the error message, "ImportError: No module named 'bankdate'.(It is required in "__init__.py" under finance.) bankdate.py seems to be file under finance folder. How could I install "bankdate"?? Does anybody help me with this??
Thank you~!
cf) pip install bankdate, easy_install bankdate don't work in this case.
I do not know if you are working with Linux or Windows. But it would be a good start checking if the package was installed properly. You could use the following code to check installed packages and its versions:
import pip
installed_packages = pip.get_installed_distributions()
installed_packages_list = sorted(["%s==%s" % (i.key, i.version)
for i in installed_packages])
print(installed_packages_list)
By doing so packages installed using both setuptools and pip will appear in a list below. If your package does not appear in the list there you have, it was not installed.
Neverhteless try to import the module usign this:
from finance import bankdate
And see if the error continue. Hope it helps.
you can use pip install finance or you can download .whl file use pip intsall .whl
you can try
Can someone that uses this tool give me a step by step manual. while I follow the available youtube manual and others on the Github I have still problems. when I want to run aligner.py I have the error
from utilities import opts2cfg, mkdir_p, \
File "/home/mary/Desktop/htk/Prosodylab-Aligner/aligner/utilities.py", line 8, in <module>
import yaml
ImportError: No module named 'yaml'
Is there any way to fix it? I try to install yaml but it seems impossible
The module should be install as pyaml. You can use pip to install Python packages. In your case this will be your installation command.
pip install pyaml