pantor / frankx

High-Level Motion Library for Collaborative Robots
https://pantor.github.io/frankx/
GNU Lesser General Public License v3.0
268 stars 65 forks source link

Can't import frankx in python3 #6

Closed poerob closed 3 years ago

poerob commented 4 years ago

Hello,

im stuck with using frankx in python3.7. I successfully build frankx with libfranka v0.7.1 and also got _frankx.cpython-37m-aarch64-linux-gnu.so and libfrankx.so in the build directory. I tried both adding the build directory to pythons path and also copying the files to diverse path folders (site-packages, dist-packages,dyn-load..) but i always get the following error when triying to import frankx:

>>> import frankx Traceback (most recent call last): File "<stdin>", line 1, in <module> ModuleNotFoundError: No module named 'frankx'

When renaming the files to "frankx.so" inside site-packages, i get: ImportError: dynamic module does not define module export function (PyInit_frankx)

Do you have any hints for fixing this? Thank you in Advance!

poerob commented 4 years ago

I gave: pip install -e . a try on my local copy of frankx and now it's working.

Before, i was the opinion that building the library and running make install would have the same effect, but obviously it doesn't. Is this expected behaviour?

pantor commented 4 years ago

At the moment, running make install does only install the C++ library but not the Python package. I should update the Readme to reflect this limitation.

guenhael commented 3 years ago

Hello,

I also successfully built frankx with libfranka but as you said in your previous message it does not install the Python package.

Can you let me know what is missing to install frankx Python package?

Thanks in advance.

nily-dti commented 3 years ago

@guenhael try to have a look at the Dockerfile to check that you have installed it as it is listed there. You might just be missing the part where we add the library to the python path environment variable.

poerob commented 3 years ago

You can also run cd ~/your_path/frankx pip install -e .

pip will call make to rebuild the library and then installs the python bindings to your environment. (At least it did that for me) Maybe you'll have to change the make arguments in /frankx/setup.py regarding your directory locations for libfranka, reflexxes, eigen3 or catch - just have a look at the error statements when pip install -e . fails.

Xiong5Heng commented 3 years ago

@poerob Hello, I run "pip install -e ." as your suggestion, but I still get the error ImportError: libfranka.so.0.7: cannot open shared object file: No such file or directory when i try the code "from frankx import Affine" By the way, I use anaconda to setup my environment.

guenhael commented 3 years ago

Hello,

@poerob, I did as you suggested and now I am in the same situation as Xiong5Heng as I am getting exactly the same error message.

nily-dti commented 3 years ago

@Xiong5Heng @guenhael have you exported the path of the build library to your pythonpath? It sounds like that is your issues. See the last line in the dockerfile i mentioned above.

guenhael commented 3 years ago

@nily-dti , yes I exported the path and I also checked the modification by running "import sys ; print(sys.path)" at the begining of the Python script. But it still cannot find frankx library. I am now wondering what should be the content of the build directory? In my case, this is what I have in that directory: CMakeCache.txt install_manifest.txt CMakeFiles libfrankx.so cmake_install.cmake linear _frankx.cpython-37m-x86_64-linux-gnu.so Makefile grasping movex.cpython-37m-x86_64-linux-gnu.so

Maybe I did something wrong in the previous steps of the installation?

poerob commented 3 years ago

Hi @Xiong5Heng @guenhael,

i recently changed my environment from anaconda to python3+venv and rebuild the current frankx version 0.1.1. The installation works flawless if you just follow the procedure described on the startpage of this repo:

git clone --recurse-submodules git@github.com:pantor/frankx.git
cd frankx
mkdir -p build
cd build
cmake -DBUILD_TYPE=Release ..
make
make install

and finally

pip3 install .

from root directory of frankx.

I changed from Anaconda because i also had problems with PYTHONPATH being ignored by conda envs. I also tried another install with the approach i explained earlier, but did not get it to work. I can't explain why pip install -e . worked for me in this one case, sorry.