Visual Studio 2022 Project Absolute import ModuleNotFoundError in python - python

Hi I am using Visual Studio 2022 for doing a python project with a tree structure (pic attached). I am unable to do absolute import and ModuleNotFoundError is coming (pic attached).
Tree Structure
Folder Layout
Relative Import
ModuleNotFoundError
Detail
Also, in Visual Studio 2022, i am unable to find Run & Debug icon for launch json setting. Please help. Python and Interpreter version is same 3.11

Related

Visual Studio puts red/green squiggles under 'cv2' and 'mediapipe' imports

I am coding in python using Microsoft Visual Studio 2022 and I have import all the libs I need , but Microsoft Visual Studio is saying they are not there when they are.
here is a picture of my setup :
the code runs and works, but both those libs are still highlighted green and The annoying thing about it is, visual Studios "autocode" is not working for those libs. So when I do cv2. nothing comes up.

install METIS library for python3 on windows7

I want to install METIS for python3.6 on windows7.I did the following steps:
1-Download the source (tar.gz or zip file) from
https://pypi.python.org/pypi/networkx-metis/
2-Unpack and change directory to the source directory (it should have the
setup.py on top level).
3-Run
python setup.py build
to build
in this step, I encountered the following error:
error: Microsoft Visual C++ 14.0 is required.
i installed "Visual Studio Tools 2017", Then I run the code again. I encountered the following error:
error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio
14.0\\VC\\BIN\\cl.exe' failed with exit status 2
I would be very grateful if you answer my questions.
Although what I used was Windows 10, perhaps the same steps as I laid out here may work for you.
First, you should get the python metis wrapper using pip: pip install metis.
Second, you must install conda-metis, which you can find here. Note, it does not require you to install Anaconda to work.
Place the files in conda-metis-master in some file path.
The installation requires some fixes. Make sure you have a recent version of Visual Studios (I used 2017). For me, VS had a problem running the instructions in BUILD-WINDOWS.txt, which landed me on this thread:
Why does MSBuild look in C:\ for Microsoft.Cpp.Default.props instead of c:\Program Files (x86)\MSBuild? ( error MSB4019)
Specifically, the answer For Visual Studio 2017 and 2019 on Windows 10 was what I went with. It could potentially be different for you since you are on Windows 7.
For the python metis package, we need to generate a metis.dll, not a metis.lib file, so we must also look closer at the CMakeLists.txt (see the Linux version of this discussion here). We add on line 19: set(METIS_LIBRARY_TYPE SHARED).
You should follow the BUILD-WINDOWS.txt instructions, but run .\vsgen -G "Visual Studio 15 2017 Win64" inside your conda-metis file path in command prompt with full permissions instead of using Visual Studio 10.
Before moving on to using the files that were generated by the above command in path_to_your_metis_dir\build\windows\, we need another fix. Following what was said in:
rint() issue after creating VS Project using CMake
we have to edit the file path_to_your_metis_dir\GKlib\gk_arch.h by removing the line: #define rint(x) ((idx_t)((x)+0.5)). (Or the fix listed on this github exchange.)
Then go to path_to_your_metis_dir\build\windows\.
Open METIS.sln in Visual Studios, go to the top to Build and from the scroll-down go to Build Solution. Afterwards, the .dll file will be in path_to_your_metis_dir\build\windows\libmetis\Release\.
Last, we run in command prompt:
set METIS_DLL=path_to_your_metis_dir\build\windows\libmetis\Release\metis.dll
After this, python metis no longer failed when I would import it into my code with the step from metis import *.

How to install METIS package in python on windows?

I am currently running a source code in python which uses METIS. I wanted to run it using Jetbrains PyCharm, conda interpreter and these are installed on windows 10. Although I have installed METIS using conda, I could not enable shared libraries and I faced this error:
ModuleNotFoundError: No module named 'metis'
When I tried to run it without conda I faced the following error although I have added the metis.dll location to the environment variables.
RuntimeError: Could not load METIS dll
Could anyone please help me about it?
This question is old, but I ran into the same problem and after going down the rabbit's hole for.. too long... I have an answer that worked for me.
First, you should get the python metis wrapper using pip: pip install metis.
Second, You must install conda-metis, which you can find here. Although pip calls the metis python wrapper metis, it just the metis wrapper and does not have metis itself.
Place the files in conda-metis-master in some file path.
The installation requires some fixes. Make sure you have a recent version of Visual Studios (I used 2017). For me, VS had a problem running the instructions in BUILD-WINDOWS.txt, which landed me on this thread:
Why does MSBuild look in C:\ for Microsoft.Cpp.Default.props instead of c:\Program Files (x86)\MSBuild? ( error MSB4019)
Specifically, the answer For Visual Studio 2017 and 2019 on Windows 10 was what I went with. Run:
set VCTargetPaths=C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\VC\VCTargets
in command prompt with full permissions to set the environment variable.
Also go to Computer\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSBuild\ in regedit and change in 4.0 the variable MSBuildOverrideTasksPath and in ToolsVersion\4.0\ the variable MSBuildToolPath to C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\15.0\Bin.
For the python metis, we need a .dll, not .lib[1], so we must also look closer at the CMakeLists.txt (see the Linux version of this discussion here). We add on line 19: set(METIS_LIBRARY_TYPE SHARED).
You should follow the BUILD-WINDOWS.txt instructions, but run .\vsgen -G "Visual Studio 15 2017 Win64" inside your conda-metis file path in command prompt with full permissions instead of using Visual Studio 10.
Wait! We need another fix before following the instructions further on using VS to build the the library. Following what was said in:
rint() issue after creating VS Project using CMake
we have to edit the file path_to_your_metis_dir\GKlib\gk_arch.h by removing the line: #define rint(x) ((idx_t)((x)+0.5)). (Or the fix listed on this github exchange.)
Then go to path_to_your_metis_dir\build\windows\.
Open METIS.sln in Visual Studios, go to the top to Build and from the scroll-down go to Build Solution. Afterwards, the .dll file will be in path_to_your_metis_dir\build\windows\libmetis\Release\.
Last, we run in command prompt:
set METIS_DLL=path_to_your_metis_dir\build\windows\libmetis\Release\metis.dll
After this, python metis no longer failed on the step from metis import * for me.
[1] If we could use .lib, then conda install -c conda-forge metis would work to get this file, but setting METIS_DLL to the .lib file leads to a windows error.
After getting the error described by #XiaojianChen , this is how I solved it (VS Studio 2022). Continuing after the above fixes, to generate a .dll file after opening up the VS solution file, go to the Solution Explorer, right click on the metis project file -> properties.
In General Properties, change the configuration type to Dynamic Library (.dll)
Screenshot of General Properties window
Under Advanced Properties, change the Target File Extension from .lib to .dll
Screenshot of Advanced Properties window
Since we only need the metis.dll file, right click the metis project file in the Solution Explorer and click build. The .dll can be found in ..\build\windows\libmetis\Release.

Unable to find vcvarshall.bar in Python 3.5

How can I get rid of this error:-
unable to find vcvarshall.bat
I am trying to compile animation nodes 2.0 addon for blender 32 bit, I can't find 32 bit version of the addon, it doesn't have wheel, I have installed anaconda, created Python 3.5 environment, Visual Studio Community 2017, visual c++ 2015 and 2017 and updated setup tools yet I still get "unable to find vcvarshall.bat"
Python 3.6 compiles the addon, but blender isn't able to accept it!
Please advise how to avoid the above error in Python 3.5.
I got it.
I installed visual c++ build tools from here: http://go.microsoft.com/fwlink/?LinkId=691126
and then i ran animation nodes 2.0 addon using x86 native command prompt which can be found in start -> all programs -> visual studio 2017 -> VC.
When i run it through default command prompt, it shows error!

gdal installation for Python Visual Studio

I want to develop GIS based GUI in python using Visual Studio 2013.
But when I am trying to using gdal it is showing error given below-
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named gdal
It would be helpful, if you let me know how to install gdal for python?
I am using Visual studio 2013 for python.
For windows, you may download from here.
Add the installation directory bin folder to your system PATH, remember to put a semicolon in front of it before you add to the existing path.
C:\gdalwin32-1.6\bin
Create a new user or system variable with the data folder from your installation.
Name : GDAL_DATA
Path : C:\gdalwin32-1.6\data
If you don't know how to do this, than suggested Microsoft KnowledgeBase documentation
For more details you may take look here for other platforms.
You should be able to install the components for various versions of MSVC and Python at this website:
http://www.gisinternals.com/
I've only used the above resource for running GDAL under Python. I've never used Visual Studio 2013 for Python, but hopefully the above resource provides the necessary components.

Categories