AI 100 Test the Face Detection API exercise - python

Error message Hi I am doing this exercise Test the Face Detection API from this page given in this link
https://learn.microsoft.com/en-us/learn/modules/identify-faces-with-computer-vision/8-test-face-detection?pivots=python
When I execute the command given below in Visual Studio Code on Python 3.5.3 64 bit, I am getting an error saying from keyword is not supported in this version. I've tried Python 3.7.4, and 3.8.6 and there also I am getting the same error.
Code
import os
from msrest.authentication import CognitiveServicesCredentials
from azure.cognitiveservices.vision.face import FaceClient
Error Message
At line:2 char:1
+ from msrest.authentication import CognitiveServicesCredentials
+ ~~~~
The 'from' keyword is not supported in this version of the language.
At line:3 char:1
+ from azure.cognitiveservices.vision.face import FaceClient
+ ~~~~
The 'from' keyword is not supported in this version of the language.
+ CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordException
+ FullyQualifiedErrorId : ReservedKeywordNotAllowed
Please advise how to fix this issue.

It seems that you're using the Python extension for VSCode.
As it is merely an interpreter that runs on PowerShell, you will still need to prepend your command with python for it to work, such as python script.py in the Visual studio code.

Related

VS Code startup <conda active base> error message

I just getting started learning with Anaconda on Visual Studio Code. Previously, I only used the Python as an interpreter. After downloaded the Anaconda and upon opening the VS Code I always encounter the following error message.
PS C:\Users\user\Documents\PythonLearn> conda activate base
conda : The term 'conda' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the
name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1
+ conda activate base
+ ~~~~~
+ CategoryInfo : ObjectNotFound: (conda:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
I already tried to install and reinstall the anaconda and go through the set environment variable but the error message still exist. The steps I used are as follows.
My Installation Process
Download Anaconda
Choice 1: Just Me (recommended)
Choice 2 (Advance): Registered Anaconda3 for the system Python 3.9
Add anaconda to environment variable
Run "Anaconda Prompt (anaconda3)" as Administrator
run where conda
Add the directory to the environment variable
where conda result
Adding the Interpreter path into the VS code
Adding the interpreter path into the VS code
Testing through a .py file
Test#1 - python:
print("Hello, world")
Hello world test#1 result
Test#2 - library:
import matplotlib.pyplot as plt
import matplotlib as mpl
import numpy as np
x = np.linspace(0, 20, 100)
plt.plot(x, np.sin(x))
plt.show()
For test#2, the terminal produce error message as follows
PS C:\Users\user\Documents\PythonLearn> & C:/Users/user/anaconda3/python.exe c:/Users/user/Documents/PythonLearn/pytest.py
C:\Users\user\anaconda3\lib\site-packages\numpy\__init__.py:148: UserWarning: mkl-service package failed to import, therefore Intel(R) MKL initialization ensuring its correct out-of-the box operation under condition when Gnu OpenMP had already been loaded by Python process is not assured. Please install mkl-service package, see http://github.com/IntelPython/mkl-service
from . import _distributor_init
Traceback (most recent call last):
File "C:\Users\user\anaconda3\lib\site-packages\numpy\core\__init__.py", line 22, in <module>
from . import multiarray
File "C:\Users\user\anaconda3\lib\site-packages\numpy\core\multiarray.py", line 12, in <module>
from . import overrides
File "C:\Users\user\anaconda3\lib\site-packages\numpy\core\overrides.py", line 7, in <module>
from numpy.core._multiarray_umath import (
ImportError: DLL load failed while importing _multiarray_umath: The specified module could not be found.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "c:\Users\user\Documents\PythonLearn\pytest.py", line 3, in <module>
import matplotlib.pyplot as plt
File "C:\Users\user\anaconda3\lib\site-packages\matplotlib\__init__.py", line 104, in <module>
import numpy
File "C:\Users\user\anaconda3\lib\site-packages\numpy\__init__.py", line 150, in <module>
from . import core
File "C:\Users\user\anaconda3\lib\site-packages\numpy\core\__init__.py", line 48, in <module>
raise ImportError(msg)
ImportError:
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.9 from "C:\Users\user\anaconda3\python.exe"
* The NumPy version is: "1.21.5"
and make sure that they are the versions you expect.
Please carefully study the documentation linked above for further help.
Original error was: DLL load failed while importing _multiarray_umath: The specified module could not be found.
PS C:\Users\user\Documents\PythonLearn>
Debugging Attempts
Previous Possible Solution: Updating Environment Variable
I reinstall and updated the new path. Still the command prompt does not recognize the conda within the system. Nevertheless, the system detects Python.
CMP_Version_Response
Testing If the Anaconda working properly
I tested the installed Anaconda file if we could detect the version or not in the directory that the Anaconda lies in. The system did detect the installed version of Anaconda.
Anaconda Exist
Ending Note / Updates
Does anyone encounter a similar problem for this error? What are your recommended solutions?
Thank you in advance for your responses. I will keep you posted If I find a solution for this.
Update#1: Restart, Re-open, Re-select path, Update
I have update the Anaconda through conda update conda and conda update anacondain the Anaconda terminal. Alongside restart the computer and re-open the terminal. Still, the error codes still exists (Error Code below) whenever I open the VS code.
. : File C:\Users\user\Documents\WindowsPowerShell\profile.ps1 cannot be loaded because running scripts is disabled on this system. For more
information, see about_Execution_Policies at https:/go.microsoft.com/fwlink/?LinkID=135170.
At line:1 char:3
+ . 'C:\Users\user\Documents\WindowsPowerShell\profile.ps1'
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : SecurityError: (:) [], PSSecurityException
+ FullyQualifiedErrorId : UnauthorizedAccess
PS C:\Users\user\Documents\PythonLearn> conda activate base
conda : The term 'conda' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or
if a path was included, verify that the path is correct and try again.
At line:1 char:1
+ conda activate base
+ ~~~~~
+ CategoryInfo : ObjectNotFound: (conda:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
PS C:\Users\user\Documents\PythonLearn>
Have you installed conda while VS Code still opened?
VS Code terminal does not update it's PATH, initialization of PATH comes at start of terminal same goes for CMD.
My only solution is to re-open VS Code or start a new terminal in terminal section in navbar inasmuch as you have conda installed on Windows and CMD confirmed it
Interpreter path updates periodically.

Visual studio code cant find python import

Visual studio code cant find imports that are obviuously installed.
No tensorflow no pygame no nothing.
I used """pip install """ for everything, And it wont find it.
Pycharm does find it but only by downloading it using pycharm.
I have no idea what to do.
And this is the error message:
"""
Exception has occurred: ModuleNotFoundError
No module named 'tensorflow'
File "D:\a game 2\python\github\computer\main.py", line 3, in
import tensorflow
"""
And for some reason i get this error for every file, not just with custom imports:
"""
pyenv : File C:\Users\rocko.pyenv\pyenv-win\bin\pyenv.ps1 cannot be loaded because running scripts is disabled on this system. For more information, see about_Execution_Policies at
https:/go.microsoft.com/fwlink/?LinkID=135170.
At line:1 char:1
pyenv shell 3.10.0b3
+ CategoryInfo : SecurityError: (:) [], PSSecurityException
+ FullyQualifiedErrorId : UnauthorizedAccess
"""
Have you tried changing the Python version used? Press [ctrl] + [shift] + [p] and search for select Python: select interpreter.

When Writing Python in Powershell it Returns Nothing

**PS C:\Users\Shaad> python**
Program 'Python' failed to run: No application is associated with the specified file for this operationAt line:1 char:1
+ python
+ ~~~~~~.
At line:1 char:1
+ python
+ ~~~~~~
+ CategoryInfo : ResourceUnavailable: (:) [], ApplicationFailedException
+ FullyQualifiedErrorId : NativeCommandFailed
I am Finding for Quick Help and Also Need to Know why My python manage.py runserver Command in Django is Not Working properly anywhere.
I think the only problem is python command Not Working Please help as SOON.
I think your python application isn't added to windows path. Firstly Add Python to the Windows Path and then try again.

OpenERP & Python Tools for Visual Studio compile error

I'm trying to get the OpenERP server to build and run in Visual Studio 2012 using Python Tools for Visual Studio.
At the moment I get more than 2300 error messages, mostly along the lines of:
unexpected token 'x1'
I've downloaded the openerp-server-6.0.4 source and created a new Python project from Existing Python Code project in VS. I've selected the path to the OpenERP source(C:\OpenERP\Bin) when prompted and the file to execute when F5 is pressed is openerp-server.py. I've selected the Python 64-bit 3.3 interpreter.
The project is created, but even before building I receive the numerous unexpected token errors. For example in the account.py file it complain about an unexpected token 'tax' in the following code:
tax.type=='code':
address = address_id and obj_partener_address.browse(cr, uid, address_id) or None
localdict = {'price_unit':cur_price_unit, 'address':address, 'product':product, 'partner':partner}
exec tax.python_compute in localdict
amount = localdict['result']
data['amount'] = amount
When using TOOLS > Python Tools > Execute Project in Python Interactive I see the following result:
Python interactive window. Type $help for a list of commands.
Resetting execution engine
Interactive window is not yet started.
Running C:\temp\openerp-server-6.0.4\bin\openerp-server.py
Traceback (most recent call last):
File "C:\temp\openerp-server-6.0.4\bin\openerp-server.py", line 64, in
import tools
File "C:\temp\openerp-server-6.0.4\bin\tools__init__.py", line 23, in
import win32
ImportError: No module named 'win32'
Can anyone guide me into getting OpenERP to build and run using VS? Is it even possible?
Thank you!
You have to install
http://www.py2exe.org/index.cgi/PyOpenGL
Please try after install this module.

Hide unresolved import error

I work with the Python plugin for Eclipse : PyDev on Linux and I'm writing a cross-platform application.
In this application, I have the following lines code :
try :
from win32com.shell import shellcon, shell
appdata_path = shell.SHGetFolderPath(0, shellcon.CSIDL_APPDATA, 0, 0)
except :
appdata_path = os.environ['APPDATA']
PyDev show me 2 errors :
Unresolved import: shell
Unresolved import: shellcon
These errors appears because the pywin32 extensions aren't installed on my system and I can't install it because there are windows extensions, not linux.
Is it have a way to hide or ignore (only) these errors ?
Thanks
Click Ctl + 1 on the failing import line and select #UnresolvedImport error
or manually, make like this:
import Afailure ##UnresolvedImport

Categories