Giter Club home page Giter Club logo

Comments (19)

andrewramsay avatar andrewramsay commented on July 28, 2024 1

The version of setup.py in the windows branch relies on a couple of environment variables to determine the location of the librealsense files, since they could be almost anywhere on a Windows system. All you should need to do is set a variable called PYRS_INCLUDES to the folder containing the librealsense headers, and another called PYRS_LIBS to the folder containing realsense.lib.

It sounds like you've bypassed the setting of PYRS_INCLUDES by editing setup.py directly, but you will still need to tell it where to find realsense.lib for the compilation to succeed.

from pyrealsense.

randyyork123 avatar randyyork123 commented on July 28, 2024

Thank you very much and please do pardon the newbie struggle!

Instead of modifying the setup file, I simply added the PYRS_INCLUDES and PYRS_LIBS environment variables, which allowed the setup to complete successfully.

When attempting to run the OpenCV example, I received the error "Unable to invoke 'cpp'. Make sure its path was passed". This implies that pycparser cannot find cpp.exe.

My first thought was to add this to my PATH, but I believe vcvarsall.bat can be run to set up the various environment variables automatically. This still did not help. I looked into the issue and it seems the Visual Studio C++ compiler command line executable is named cl.exe. I naively created a copy named cpp.exe and am now getting this error:

"cl : Command line warning D9024 : unrecognized source file type 'C:\RealSense\include\librealsense\rs.h', object file assumed"

I also tried compiling with MinGW, with an error related to this line: "rsutilwrapper = ctypes.CDLL(_find_extension_name())" and for some reason not being able to locate rsutilwrapper.pyd.

from pyrealsense.

andrewramsay avatar andrewramsay commented on July 28, 2024

From a quick look at the pycparser FAQ, I'm not sure VC++ is the best choice as they recommend using other compilers on Windows. It might work but definitely not by simply renaming cl.exe. The parameters it expects will be totally different and you'd probably have to modify the way pyrealsense calls pycparser to fix that issue.

I would suggest that you go back to compiling pyrealsense with VC++ since that was working for you, and then just add the MinGW/bin directory to your PATH. It should contain a valid copy of cpp.exe and so allow things to work as they're supposed to do. This is the setup I have myself and it seems to work fine for me on a Win10 machine.

from pyrealsense.

randyyork123 avatar randyyork123 commented on July 28, 2024

Finally got it working, thanks for your help!


Some details:
I placed MinGW's bin folder in the PATH and successfully reinstalled the pyrealsense library. That being said, I continued to receive the error when attempting to import the pyrealsense library (or running the OpenCV example).

The error message states the module could not be located, pointing to this line:
rsutilwrapper = ctypes.CDLL(_find_extension_name()))

After some questioning (and cursing!), I ran Process Monitor (https://technet.microsoft.com/en-us/sysinternals/processmonitor.aspx) and realized that the error is caused by Python not being able to locate the previously-compiled realsense libraries. This is odd because the PATH is correctly set.

For now, I placed the compiled libraries in the C:\Python27 folder and all is well.

from pyrealsense.

andrewramsay avatar andrewramsay commented on July 28, 2024

That does seem strange. If the .pyd file is in the same location as the rest of the pyrealsense source files and the folder containing realsense.dll is on the PATH then everything should just work. But good to hear it's working now anyway, thanks for testing it on Windows!

from pyrealsense.

GiantDeveloper021 avatar GiantDeveloper021 commented on July 28, 2024

Camera Model = R200
Operating System = Windows 10
pyrealsense version =1.4
python = 3.6.7

I hope you guys are doing well. when i install pyrealsense using pip install pyrealsense==1.4 having librealsense verison 1.12.1 it generates me following error;

pyrealsense/rsutilwrapper.c(1): fatal error C1083: Cannot open include file: 'rs.h': No such file or directory

but when i install using pip install pyrealsense then it generates following error;

LINK : fatal error LNK1181: cannot open input file 'realsense.lib'

i have set environment variables in users that are PYRS_INCLUDES AND PYRS_LIBS and given the path as shown in the pic below;

image

I will be very thankful if you guys could help me. Thanks is advance!

from pyrealsense.

toinsson avatar toinsson commented on July 28, 2024

Hello,
I have no access to a windows machine right now so won't be able to check solutions.

It might be useful to make sure the terminal you execute the commands from has indeed both variables (PYRS_INCLUDES, PYRS_LIBS) set. You could check with echo %VAR%.

The problem you encounter is clearly a variable issue.

from pyrealsense.

GiantDeveloper021 avatar GiantDeveloper021 commented on July 28, 2024

Thanks for replying. i checked the variables using echo and they both outputted the same path as given in environment variable. See the screenshot below;

image

from pyrealsense.

andrewramsay avatar andrewramsay commented on July 28, 2024

I think you have a couple of different problems here:

  • If I remember correctly PYRS_LIBS should be set to the directory containing realsense.lib, not the full path to the file itself
  • Is there a reason you're trying to use v1.4? That version seems to be too old to have had the Windows workaround with the 2 environment variables in setup.py, that was in the 2.0 release. You can see the v1.4 version here for reference. If you really need to use that specific version you'll have to add the workaround back in yourself and deal with any other problems that crop up
  • If the installer script is picking up your env vars, you should see that in the compiler output. For example your second screenshot doesn't show a -IF:\FYP\Libraries\librealsense-1.12.1\include\librealsense parameter when calling cl.exe, it should be there if the env var is visible to the setup.py script. Similarly when it tries to link to the .lib file at the next step you should be seeing a /LIBPATH:F:\FYP\Libraries\librealsense-1.12.1\bin\Win32 parameter. In your screenshot they aren't there because of the v1.4 script not checking for the env vars, but if you try a newer release that should allow you to verify they're being detected correctly

from pyrealsense.

GiantDeveloper021 avatar GiantDeveloper021 commented on July 28, 2024

Thanks for your response:

  • Ok now i have changed the path to F:\FYP\Libraries\librealsense-1.12.1\bin\Win32 .
  • No not really i was just giving it a try.
  • After changing the path it's now showing both variables path but with new errors. This time i tried pip install pyrealsense --user.

image

from pyrealsense.

andrewramsay avatar andrewramsay commented on July 28, 2024

Maybe an x64/x86 mismatch? It looks like you're using 64-bit Python here but the PYRS_LIBS path ends in "bin/Win32" which usually implies 32-bit binaries, so that could be why it's not resolving symbols correctly. If you have a "bin/x64" folder there with a realsense.lib inside I'd try that path instead.

from pyrealsense.

GiantDeveloper021 avatar GiantDeveloper021 commented on July 28, 2024

Thank you for the response! Ok i tried rebuilding the solution which created folder x64 in binary folder in which realsense.lib was created with some other .exe files and changed the path to x64 and then tried pip install pyrealsense --user but now it gives following error;

image

from pyrealsense.

andrewramsay avatar andrewramsay commented on July 28, 2024

I don't think this is anything to do with pyrealsense at this point. It's successfully compiled and linked the module and is failing for some reason trying to run rc.exe which is the Visual Studio Resource Compiler tool.

From a quick Google you may have hit this bug which was fixed last year... but according to your screenshot you're using a version of pip that's about 3 years old, so you might have other outdated modules too!

If this is a Python 3.6 installation you've been using for a long time you might want to start over with a fresh install of 3.8 or 3.9 to make sure things are properly up to date. At the very least I would try upgrading your versions of pip and setuptools.

from pyrealsense.

GiantDeveloper021 avatar GiantDeveloper021 commented on July 28, 2024

I uninstalled python 3.6 and installed the latest python 3.9 and updated pip too but it still shows me this ;

image
image

I missed the part that i am using visual studio 2015 update 5 as librealsense 1.12.1 was tested successfully on that. Before that , I tried to run librealsense 1.12.1 on visual studio 2019 but errors occured.

Sorry due to some circumstances i couldn't reply back early.

from pyrealsense.

andrewramsay avatar andrewramsay commented on July 28, 2024

As I said, I don't think this is a pyrealsense problem. The error is appearing during the compilation + linking of the C++ extension module, and that whole process is handled in a standard way by distutils/Cython. It's clearly picking up your env vars correctly which is the only pyrealsense-specific step in the whole process.

I've just gone through the process of installing pyrealsense on a Win10 system:

  • Python 3.9.5 x64
  • VS 2019 (v16.11.3)
  • Windows SDK v10.0.19041.0
  • MSVC build tools v142
  • librealsense-1.12.1

With that configuration it compiled + installed without any trouble. My guess is that there's something wrong with your Visual Studio setup. Have you tried installing any other Python modules that require compilation like this?

If you google that link.exe error code you can see a bunch of people reporting problems with Python modules and VS 2015 (aka 14.0) which is what you're using. If you look into the suggested solutions involving rc.exe and rcdll.dll I think that would be your best bet for fixing this.

from pyrealsense.

GiantDeveloper021 avatar GiantDeveloper021 commented on July 28, 2024

Ok so the good news is that pyrealsense-2.2 successfully installed with the help of this solution but the bad news is that when i import pyrealsense it generates following error;

image

from pyrealsense.

GiantDeveloper021 avatar GiantDeveloper021 commented on July 28, 2024

As I said, I don't think this is a pyrealsense problem. The error is appearing during the compilation + linking of the C++ extension module, and that whole process is handled in a standard way by distutils/Cython. It's clearly picking up your env vars correctly which is the only pyrealsense-specific step in the whole process.

I've just gone through the process of installing pyrealsense on a Win10 system:

  • Python 3.9.5 x64
  • VS 2019 (v16.11.3)
  • Windows SDK v10.0.19041.0
  • MSVC build tools v142
  • librealsense-1.12.1

With that configuration it compiled + installed without any trouble. My guess is that there's something wrong with your Visual Studio setup. Have you tried installing any other Python modules that require compilation like this?

If you google that link.exe error code you can see a bunch of people reporting problems with Python modules and VS 2015 (aka 14.0) which is what you're using. If you look into the suggested solutions involving rc.exe and rcdll.dll I think that would be your best bet for fixing this.

yep i copy/paste both files into visual studio folder which solved the issue but now the problem is that i cannot import it as shown in the fig above . Thanks for the early reply

from pyrealsense.

andrewramsay avatar andrewramsay commented on July 28, 2024

It's giving you an extremely clear error message that should have helped you search for solutions. There's even an earlier post in this same issue where that exact problem is mentioned.

Unable to invoke 'cpp' ==> it tried to run a cpp executable and it can't find one.

The exception is obviously coming from the pycparser module which has a README that explains you will need a compatible binary available under Windows.

from pyrealsense.

GiantDeveloper021 avatar GiantDeveloper021 commented on July 28, 2024

I will look into it . Thank you for helping me!

from pyrealsense.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.