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.
Related
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.
My picture won't upload due to server issues but essential the error for just a print command returns as:
Program 'python.exe' failed to run: The system cannot find the path specified line:1 char:1
+python main.py
+
At line:1 char:1
+python main.py
+
+ Category Info : ResourceUnavailable: (:) [], ApplicationFailedException
+ Fully QualifiedErrorId : NativeCammandFailed
I was having an issue with pycharm so I unistalled and reinstalled it, downloaded python 3.10.8, and now I am having this new error.
There is a similar question. I think we can refer to the reply here.
Use shortcuts "win+R" and type PowerShell.exe "Start-Process "cmd" -Verb runas".
Copy the following commands, then right-click in the open command prompt window, click "Paste" (or ctrl+v), and press Enter to execute:
CMD /C "ICACLS "%ProgramFiles%\WindowsApps" /setowner "NT SERVICE\TrustedInstaller" & ECHO Y|CACLS "%ProgramFiles%\WindowsApps" /S:"D:PAI(A;;FA;;;S-1-5-80-956008885-3418522649-1831038044-1853292631-2271478464)(A;OICIIO;GA;;;S-1-5-80-956008885-3418522649-1831038044-1853292631-2271478464)(A;;0x1200a9;;;S-1-15-3-1024-3635283841-2530182609-996808640-1887759898-3848208603-3313616867-983405619-2501854204)(A;OICIIO;GXGR;;;S-1-15-3-1024-3635283841-2530182609-996808640-1887759898-3848208603-3313616867-983405619-2501854204)(A;;FA;;;SY)(A;OICIIO;GA;;;SY)(A;CI;0x1200a9;;;BA)(A;OICI;0x1200a9;;;LS)(A;OICI;0x1200a9;;;NS)(A;OICI;0x1200a9;;;RC)(XA;;0x1200a9;;;BU;(Exists WIN://SYSAPPID))""
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.
**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.
I am trying to use Openpose from windows and i need to run .py file. But i couldn't find any command to install pyopenpose module So where can I find pyopenpose module?
I tried this command on cmd:
C:\openpose\examples\tutorial_api_python>python 01_body_from_image.py
I get the error :
Error: OpenPose library could not be found. Did you enable `BUILD_PYTHON` in CMake and have this Python script in the right folder?
Traceback (most recent call last):
File "01_body_from_image.py", line 26, in <module>
raise e
File "01_body_from_image.py", line 17, in <module>
import pyopenpose as op
ModuleNotFoundError: No module named 'pyopenpose'
The error in general is that PyOpenPose cannot be found (an error similar to: ImportError: cannot import name pyopenpose). Ensure first that BUILD_PYTHON flag is set to ON. If the error persists, check the following:
In the script you are running, check for the following line, and run the following command in the same location as where the file is.
Ubuntu/OSX:
sys.path.append('../../python');
ls ../../python/openpose
Check the contents of this location. It should contain one of the following files:
pyopenpose.cpython-35m-x86_64-linux-gnu.so
pyopenpose.so
If you do not have any one of those, you may not have compiled openpose successfully, or you may be running the examples, not from the build folder but the source folder. If you have the first one, you have compiled PyOpenPose for Python 3, and have to run the scripts with python3, and vice versa for the 2nd one. Follow the testing examples above for exact commands.
Windows:
Problem 1: If you are in Windows, and you fail to install the required third party Python libraries, it might print an error similar to: Exception: Error: OpenPose library could not be found. Did you enable BUILD_PYTHON in CMake and have this Python script in the right folder?. From GitHub issue #941:
I had a similar issue with Visual Studio (VS). I am pretty sure that the issue is that while you are compiling OpenPose in VS, it tries to import cv2 (python-opencv) and it fails. So make sure that if you open cmd.exe and run Python, you can actually import cv2 without errors. I could not, but I had cv2 installed in a IPython environment (Anaconda), so I activated that environment, and then ran (change this to adapt it to your VS version and location of OpenPose.sln):
C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild.exe
C:\path\to\OpenPose.sln
Problem 2: Python for Openpose needs to be compiled in Release mode for now. This can be done in Visual Studio. Once that is done check this line:
sys.path.append(dir_path + '/../../python/openpose/Release');
dir ../../python/openpose/Release
Check the contents of this location. It should contain one of the following files:
pyopenpose.cp36-win_amd64.pyd
pyopenpose.pyd
If such a folder does not exist, you need to compile in Release mode as seen above. If you have the first one, you have compiled PyOpenPose for Python 3, and have to run the scripts with python3, and vice versa for the 2nd one. Follow the testing examples above for exact commands. If that still does not work, check this line:
os.environ['PATH'] = os.environ['PATH'] + ';' + dir_path + '/../../x64/Release;' + dir_path + '/../../bin;'
dir ../../x64/Release
dir ../../bin
Ensure that both of these paths exist, as PyOpenPose needs to reference those libraries. If they don't exist, change the path so that they point to the correct location in your build folder.