storj-thirdparty / uplink-python

Python bindings for libuplink
https://storj.io
Apache License 2.0
20 stars 10 forks source link

Error when importing the library #1

Closed Alejoss closed 3 years ago

Alejoss commented 4 years ago

ModuleNotFoundError: No module named 'exchange'

after pip install exchange

name 'Structure' is not defined

ayush-srivastava-03 commented 4 years ago

Hello @Alejoss , Please confirm you followed these steps to install uplink-python module and add it to your project?

1. Install module:
pip install --no-cache-dir uplink-python
OR
pip install uplink-python

2. Import module to new project:
from uplink_python.uplink import *

Also, please confirm you are using python 3.4 or above.

Alejoss commented 4 years ago

Ok I reinstalled everything, including python and the virtualenv. So I'm in python 3.8.4 now I get this error:

OSError: /home/safaltaya/Proyectos/magicvenv/lib/python3.8/site-packages/uplink_python/libuplinkc.so: cannot open shared object file: No such file or directory

Dunno what was causing the last error, this one looks like a death end. I'll come back and report here if I find something. I get the error when declaring the variable

uplink = LibUplinkPy()

ayush-srivastava-03 commented 4 years ago

Hello @Alejoss It seems you have installed uplink-python correctly, the issue you are currently facing is when OS restrict pip to create OS dependent dynamic-library libuplinkc.so. This is commonly due to permission issues.

Following these steps to create the libuplinkc.so manually would resolve the issue: https://github.com/storj-thirdparty/uplink-python#option-2

Let me know if you have any other doubts or face any issue creating the libuplinkc.so.

Alejoss commented 4 years ago
go get storj.io/uplink-c
package storj.io/uplink-c: unrecognized import path "storj.io/uplink-c" (parse https://storj.io/uplink-c?go-get=1: multiple meta tags match import path "storj.io/uplink-c")

Thats what I get. I'm on python 3.8.4 inside a virtualenv. I tried it outside the venv and got the same error though.

ifraixedes commented 4 years ago

I also installed following what's commented in the option 1 and while the installation succeeded

-> pip3 install --no-cache uplink-python
Collecting uplink-python
  Downloading uplink-python-1.0.3.tar.gz (14 kB)
Requirement already satisfied: wheel in /usr/lib/python3/dist-packages (from uplink-python) (0.34.2)
Building wheels for collected packages: uplink-python
  Building wheel for uplink-python (setup.py) ... done
  Created wheel for uplink-python: filename=uplink_python-1.0.3-py3-none-any.whl size=13027 sha256=31ea7df2589059efec0506797927383109ce5696b76dba9a1499b0e2d17634bb
  Stored in directory: /tmp/pip-ephem-wheel-cache-ware1ytl/wheels/b8/19/91/2302edcd815817df9cb93a18fee54dd12e12b74cdfd319e9a2
Successfully built uplink-python
Installing collected packages: uplink-python

There is the following error when I execute the hello_storj.py file present in this repository under the uplink_python directory.

-> python3 hello_storj.py
Traceback (most recent call last):
  File "hello_storj.py", line 162, in <module>
    StorjObj = LibUplinkPy()
  File "/usr/local/lib/python3.8/dist-packages/uplink_python/exchange.py", line 115, in __init__
    self.m_libuplink = c.CDLL(so_path)
  File "/usr/lib/python3.8/ctypes/__init__.py", line 373, in __init__
    self._handle = _dlopen(self._name, mode)
OSError: /usr/local/lib/python3.8/dist-packages/uplink_python/libuplinkc.so: cannot open shared object file: No such file or directory

The error is obvious, it cannot find the libuplinkc.so file under the installation directory because it doesn't exist.

-> ls /usr/local/lib/python3.8/dist-packages/uplink_python
constants.py  exchange.py  hello_storj.py  __init__.py  __pycache__  uplink.py

I think that there is some bug in the setup script.

ayush-srivastava-03 commented 4 years ago

@Alejoss kindly share output of the following commands.

1) go version
2) go env
ayush-srivastava-03 commented 4 years ago

Hello @ifraixedes Yes the issue you are facing is due to libuplinkc.so file which was not created in your installation path. In your case it is due to the directory where the module is installed. libuplinkc.so will only be created in site-packages (standard pip) directory, but in your case it is dist-packages, so you will have to follow Option 2

ifraixedes commented 4 years ago

Please, write that issue in option 1 so nobody else will fall in the same trap. Many thanks in advance.

ayush-srivastava-03 commented 4 years ago

@ifraixedes Thanks for the suggestion, we will definitely add these details to readme in next update.