Can't get the subnet id of azure using python - azure-virtual-network

I want to get the resource id of a subnet in a virtual network in azure using python, the command i have used is this line : subnets=network_client.subnets.get(resource_group,'XXX','XXX')
But what I get is an error: HttpResponseError: (InvalidApiVersionParameter) The api-version '2021-02-01' is invalid. The supported versions are '2021-04-01,2021-01-01,2020-10-01,2020-09-01,2020-08-01,2020-07-01,2020-06-01,2020-05-01,2020-01-01,2019-11-01,2019-10-01,2019-09-01,2019-08-01,2019-07-01,2019-06-01,2019-05-10,2019-05-01,2019-03-01,2018-11-01,2018-09-01,2018-08-01,2018-07-01,2018-06-01,2018-05-01,2018-02-01,2018-01-01,2017-12-01,2017-08-01,2017-06-01,2017-05-10,2017-05-01,2017-03-01,2016-09-01,2016-07-01,2016-06-01,2016-02-01,2015-11-01,2015-01-01,2014-04-01-preview,2014-04-01,2014-01-01,2013-03-01,2014-02-26,2014-04'.
I have tried different api versions but it's getting me errors.Any idea please ?
The version of azure-mgmt-network I used is 19.0.0

Please make sure that you have the below two models installed first before executing the script:
pip install azure-mgmt-network
pip install azure-identity
Then use the below script to get the subnet-id of specific subnet present in your subscription:
from azure.identity import AzureCliCredential
from azure.mgmt.network import NetworkManagementClient
credential = AzureCliCredential()
subscription_id = "948d4068-xxxx-xxxx-xxxx-e00a844e059b"
network_client = NetworkManagementClient(credential, subscription_id)
resource_group_name = "ansumantest"
location = "West US 2"
virtual_network_name = "ansuman-vnet"
subnet_name = "acisubnet"
Subnet=network_client.subnets.get(resource_group_name, virtual_network_name, subnet_name)
print(Subnet.id)
Output:
Note : I am using pip version pip 21.2.4 and (python 3.9). The pip models version that I am using are as below :
I am using the same network model version as you . But if you are still facing the issue then trying installing the new one i.e. 19.1.0 .

Related

How to import cplex.jl on google colab

I need to create a optimization problem with the cplex library and julia. I have to use colab for this, I was able to create a colab on the julia template and download the JuMP library. I have a student license on cplex. But when I try to download cplex it gives the following error:
Error building `CPLEX`:
ERROR: LoadError: Unable to install CPLEX.jl.
The versions of CPLEX supported by CPLEX.jl are:
* 12.10
* 20.1
You must download and install one of these versions separately.
You should set the `CPLEX_STUDIO_BINARIES` environment variable to point to
the install location then try again. For example (updating the path to the
correct location if needed):
# On Windows, this might be
ENV["CPLEX_STUDIO_BINARIES"] = "C:\\Program Files\\CPLEX_Studio1210\\cplex\\bin\\x86-64_win\\"
import Pkg
Pkg.add("CPLEX")
Pkg.build("CPLEX")
i tried the import Pkg; Pkg.add("CPLEX") and upload the I uploaded the cplex files on the computer and showed the path there:
ENV["CPLEX_STUDIO_BINARIES"] = "/content/x64_win64"
import Pkg
Pkg.add("CPLEX")
Pkg.build("CPLEX")

Google Speech API cannot import name 'enums'

I am trying to use Google Speech API to recognize speech, on windows with colab
here is the error
ImportError: cannot import name 'enums' from 'google.cloud.speech_v1'
Anybody knows how to solve this?
Looks like in the new version they have removed enums. Check this link, If you want enums then you have to switch to an old version.
As mentioned in #addno1's answer, enums and types have been removed in the 2.x versions of the library. It seems that you are using a 2.x version of the library, hence the error.
If your code is using the 1.x version of the library and if you would like to upgrade to the latest version of the library, refer to this migration guide(same mentioned in the other answer). You can refer to this quick start for setup instructions and an updated client library code given below.
# Imports the Google Cloud client library
from google.cloud import speech
# Instantiates a client
client = speech.SpeechClient()
# The name of the audio file to transcribe
gcs_uri = "gs://cloud-samples-data/speech/brooklyn_bridge.raw"
audio = speech.RecognitionAudio(uri=gcs_uri)
config = speech.RecognitionConfig(
encoding=speech.RecognitionConfig.AudioEncoding.LINEAR16,
sample_rate_hertz=16000,
language_code="en-US",
)
# Detects speech in the audio file
response = client.recognize(config=config, audio=audio)
for result in response.results:
print("Transcript: {}".format(result.alternatives[0].transcript))
If you want to use the older code, you will have to downgrade the library version to 1.3.2 (last 1.x version) by running the pip command
pip install google-cloud-speech==1.3.2

.kaggle not found in C:/users/username/

I installed kaggle using pip install kagggle.I created a new API token but, .kaggle is not found in the location :C:/users/username/. Where do I store kaggle.json?

Cannot install uasyncio package on esp32 using upip

I have been using uasyncio on ESP32-WROOM-32D. After all the testing, I am trying to use the firmware to my other boards but uasyncio is not installed by default with the micropython. I tried to install the package by
>rshell -p comX
>repl
>>> import upip
>>> upip.install('micropython-uasyncio')
but getting the following error:
Installing to: /lib/
Error installing 'micropython-uasyncio': list index out of range, packages may be partially installed
Please help!
This is most likely a network error. I traced the same error and found that usocket.getaddrinfo failed to return a sensible address, leading to a list out of range exception in the upip module (https://github.com/micropython/micropython/blob/master/tools/upip.py#L136).
Check your network configuration using:
import network
network.WLAN(network.STA_IF).ifconfig()
If settings are not correct, make sure you have reasonable settings by calling ifconfig with a tuple of 4 addresses (ip, mask, gateway, dns):
network.WLAN(network.STA_IF).ifconfig(("192.168.1.101", "255.255.255.0", "192.168.1.1", "8.8.8.8"))

Missing package to enable rendering OpenAI Gym in Colab

I'm attempting to render OpenAI Gym environments in Colab via a Mac using the StarAI code referenced in previous questions on this topic. However, it fails. The key error (at least the first error) is shown in full below, but the import part seems to be "Please install xdpyinfo!"
PyPI doesn't have xdpyinfo. What is it and how do I install it?
Full error message:
482780428160 abstractdisplay.py:151] xdpyinfo was not found, X start can not be checked! Please install xdpyinfo!
I've seen the same error, and solved it by installing x11-utils package which includes xdpyinfo command.
!apt-get install x11-utils