Unable to import azure.functions in Pycharm - python

I am trying to create python based 'Function Apps' in Azure, but struggling with the very first step on importing azure.functions. Even the default code that is created (when a new Function App is created using Azure Portal) will have this line of code: import azure.functions as func
When I copy the code to Pycharm i get errors depending on whether i choose Conda or direct python.exe interpreter. When i do NOT use Conda i get below msg:
Starting with v5.0.0, the 'azure' meta-package is deprecated and
cannot be installed anymore. Please install the service specific
packages prefixed by azure needed for your application. .... A
more comprehensive discussion of the rationale for this decision can
be found in the following issue:
https://github.com/Azure/azure-sdk-for-python/issues/10646
If i use Conda env i get below msg:
UnsatisfiableError: The following specifications were found
to be incompatible with the existing python installation in your environment:
Specifications:
azure -> python[version='>=2.7,<2.8.0a0|>=3.5,<3.6.0a0|>=3.6,<3.7.0a0']
Your python: python=3.7
If python is on the left-most side of the chain, that's the version
you've asked for. When python appears to the right, that indicates
that the thing on the left is somehow not available for the python
version you are constrained to. Note that conda will not change your
python version to a different minor version unless you explicitly
specify that.
Given that azure.functions is the core module i am sure there is something else at wrong here, but not able to figure out.
Some of the responses for similar issues indicated to install it via pip command (pip install azure==4.0.0). I am able to run this cmd successfully on my windows10 laptop, but Pycharm still says no module found.
Any guidance is appreciated.

For the no module found error, please ensure that the modules are installed at the PyCharm end. You would need the Azure-Functions module.
File> Settings> Project :YOUR_PROJECT_NAME > Project Interpreter
If you did not find the azure-functions module.
Click on the '+' icon that is visible in the same window.
Add Azure-Functions module in the subsequent Available Packages Window like below. Click on the Install Package
Close the windows and try importing azure.functions
import azure.functions
Alternatively you can install the Azure Functions through the pip command :
https://pypi.org/project/azure-functions/
pip install azure-functions
Additional Information :
https://pypi.org/project/azure/4.0.0/
Reading through the documentation, it appears like the azure functions is not included in the Azure Module. They include only the below.
azure-mgmt v4.x
azure-applicationinsights v0.1.x
azure-batch v4.x
azure-cosmosb-table v1.x
azure-datalake-store v0.0.x
azure-eventgrid v1.x
azure-graphrbac v0.40.x
azure-keyvault v1.x
azure-loganalytics v0.1.x
azure-servicebus v0.21.x
azure-servicefabric v6.3.0.0
azure-servicemanagement-legacy v0.20.x
azure-storage-blob v1.x
azure-storage-queue v1.x
azure-storage-file v1.x
Update for Conda interpreter:
When I used the Conda interpreter.
File> Settings> Project :YOUR_PROJECT_NAME > Project Interpreter
I unselected/Unclicked the "Use Conda Package Manager" (green circle - Conda Icon) which is on the right Project Interpreter Window - Click on it to unselect it. When you unselect it, there will be no highlight behind the icon.
Now I clicked on the add('+' icon) button and searched for the azure-functions, installed the same - Above mentioned steps.

Related

Import "urllib3" could not be resolved from sourcePylancereportMissingModuleSource

I am new to Python and writing a lambda function.
I installed urllib3 using pip but still getting this following error.
I tried restarting vscode/ uninstall and reinstall but still getting the error.
this is the result when I run pip show urllib3
what am i missing here?
You need to make sure that VS Code uses the same Python Interpreter that you installed this package to.
You can see it here:
Looks like yours should point to
c:\user\###\appdata\local\programs\python\python39\bin\python
(or something like that, where your python executable file is located)
Maybe there is more than one python environment on your machine, And the location where you installed the package is inconsistent with the python interpreter you are using now.
You can use CTRL + SHIFT + P to open the command palette and search Python: Select Interpreter (or click on the interpreter version displayed in the lower right corner).
Select the environment interpreter where you have the urllib3 package installed.

Databricks init script is failing to install packages but reporting as "Succeeded" regardless?

I have been attempting to setup 'init scripts' on databricks, so I can install all of my python libraries and keep the environment controlled.
Tried yesterday using the init script pictured below:
dbutils.fs.put("/DA/Temp/ClusterTest/python_requirements_test2.sh","""
#!/bin/bash
pip install pyodbc==4.0.32
pip install zeep==4.1.0
""", True)
This was successful!
But after trialling some other techinques and coming back to this method, the init script is no longer installing any of the libraries..
Can anyone shed some light on this?
Below is the 'Event Log' note about the init script, showing "Status: SUCCEEDED" even though no libraries are actually installed:
When you install a library on a cluster, a notebook already attached
to that cluster will not immediately see the new library. You must
first detach and then reattach the notebook to the cluster.
To View the libraries installed on a cluster:
Click compute icon Compute in the sidebar.
Click the cluster name.
Click the Libraries tab. For each library, the tab displays the name and version, type, install status, and, if uploaded, the source file.
After a conversation with Databricks support team, it is an intended functionality of their Clusters UI to NOT show packages installed via init script in the UI. These packages are installed however and this does not indicate that the packages arent installed.
I have asked the support team to update their documentation on this, as it was not clear that this was an intended behaviour.

How do I import Pandas library into PyCharm?

I have downloaded Pandas library with pip install pandas through the command prompt, when I try to import pandas as pd PyCharm returns an error : ModuleNotFoundError: No module named 'pandas'
I have tried to uninstall and install again many times but nothing seems to work. Does anybody know a solution to this?
You can try downloading the library from PyCharm settings:
File -> Settings
then, Project: -> Python Interpreter
Click a + sign to the right,
Search for the pandas library,
and finally, press 'Install Package'
I think you have to choose the right python interpreter. Check my screenshot
You likely have multiple copies of Python installed on your system. PyCharm can be configured to use any version of Python on your system, including any virtual environments you've defined. The solution is to match up the version of Python you've installed Pandas into with the version of Python that PyCharm is using to run your code.
There are two places where you specify a Python version. First of all, your Project has a version associated with it. Check the "Python Interpreter" section of the "Project" section of your Preferences for that. That version is used for syntax highlighting, code completion, etc.
By default, the abovementioned Python version will also be used to run your code. But you can change the version of Python that your code is run with by creating or modifying a Run Configuration. To do this, check the menu next to the Run and Debug toolbar buttons near the top-left of your PyCharm window.
When you do get into the Python Interpreter section of the Preferences, you'll find that you can see all of the modules installed for each Python version that PyCharm knows about. You can use this to check to see if Pandas is installed for a particular Python version.
I would suggest you get comfortable with all that I've said above. It will save you many headaches in the future.

How do i install a Prject interpeter that cannot be found in the pycharm explorer

I am trying to install the huobi_python lib to my pycharm however i'm unable to do so. I have tried multiple times to add it and google it but did not succseed. Does anyone know how to fix this?
Github link:https://github.com/huobiapi/huobi_Python
Running windows 10, no i cannot find it in Project interpeter and with the + sign. Those are mostly REST api's
You wouldn't add it as an interpreter.
Since the project isn't available as pip install, you'd have to build it from source. Meaning clone the repo, and run the command listed in the installation section from the command prompt. Also make sure that you're using Python3.7, as listed there.
Your interpreter then would have to just be Python 3.7, which will allow you to import the modules from other Python code
from huobi import RequestClient
# your code

Robot Framework with Pycharm -- Autocomplete doesn't work

I've installed PyCharm with the robotframework support plugin.
The .robot files are identified successfully and I was able to create a simple script and run it in pyCharm.
However, my problem is that no keywords nor even the robotframework libraries (selenium2library) are recognized by pycharm in order to be autocompleted when typing them.
I also have the intellibot plugin installed.
Is there something that I'm missing? Is there another configuration file somewhere?
Thanks,
Try to set up your Library to robotframework-selenium2library == 1.8.0, then the issue will disappear.
If you have the last version it doesn't work for me.
My solution:
Uninstall the 'Robot framework support' (PyCharm/File/Settings/Plugins)
Uninstall 'Intellibot' (PyCharm/File/Settings/Plugins) (Uninstall all similar plugins!)
Exit PyCharm
Uninstall robotframework-seleniumlibrary (Open command prompt with administration mode: pip uninstall robotframework-seleniumlibrary)
Install robotframework-seleniumlibrary 3.3.1 (Command prompt: pip install robotframework-seleniumlibrary==3.3.1)
Open PyCharm
Install 'IntelliBot #SeleniumLibrary Patched' (PyCharm/File/Settings/Plugins)
(If it isn't working then try the following: PyCharm/File/Invalidate Caches/Restart... and click the 'Invalidate and Restart')
There is a bug in the intellibot plugin.
To resolve you need to
1. Uninstall your current intellibot plugin
2. Search for "IntelliBot #SeleniumLibrary Patched" in the plugins repository.
3. Install this patched plugin.
This worked for me.
You can try install "Robot Framework support" plugin.
it working for me.
use plugin Intellbot#SeleniumLibrary Patched
and robotframework-seleniumlibrary version 3.3.1
It works for me after lot of research from the internet
I recomend to use lte2000 fork: https://github.com/lte2000/intellibot
It works fine for me (Pycharm 2020.1, Robot Framework 3.2.2 and SeleniumLibrary 4.5.0)
In our main_resources.robot we need to give file path as below for the library files which contain definition of function
Library ../lib/SampleRest/SampleRest.py
When you do cntl+click on above SampleRest.py it should be navigated to that file
Your SampleRest.py should contain all your function definitions as below
try:
from .api import *
except:
from api import *
class SampleRest(
events,
repository,
devices
):
"""
This library will provides keywords to automating the cloud test cases
"""
ROBOT_LIBRARY_SCOPE = 'GLOBAL'
ROBOT_LIBRARY_VERSION = 1.0
def __init__(self):
for base in SampleRest.__bases__:
base.__init__(self)
Once I declare this I can use any of functions present in above devices.py file from robot file and it will be successfully navigated
Also please check your robotframework-seleniumlibrary version it should be 3.3.1 because for latest version navigation is an issue
I have been troubled by this for what seems to be forever.
Here are my configuration steps, and so far everything is working like a charm.
My setup:
Installed Python 3.9.x => added path to variables in "windows environment Variables" Check python and pip versions.
install selenium
install robotframework
install robotframework-seleniumlibrary
Install Pycharm and set Interpreter to Python 3.9.x
Install Plugin: "IntelliBot #SeleniumLibrary Patched" - Do not install Selenium2Library This is what causes the IDE issues.
Restart IDE and enjoy. And for those just getting into Robotframework, dont forget to add webdrivers.
For this I made a folder in root (called it webdrivers) and also added this to my Windows Enviro variables. This allows me to call them from any project folder.
I am going through the same problems... I've tried IntelliBot, IntelliBot #patched, Robot Framework Support plugins.
Now I am testing the Hyper RobotFramework Support plugin [link] and for now, looks the best from all of these.
With it I have some auto-complete support, also ctrl+click (navigation) works nice (better than in IntelliBot). Not perfect, but the best it has been so far.
I have installed:
PyCharm 2021.3.2
Python 3.10.2
Robot Framework 4.1.3
selenium 4.1.3
robotframework-seleniumlibrary 6.0.0
(on windows you can run the command pip list to see the version of the libraries that have been installed using pip)

Categories

Resources