简体   繁体   中英

Installing package on MS Azure when PIP doesnt work

I'm trying to install this https://github.com/mrjbq7/ta-lib package on MS Azure Jupyter notebook environment. In my local anaconda environment, this all worked well.

PIP produces the first error that is described in the troubleshooting section, but I dont understand the solution.

Next, I tried the terminal on the azure project site, but when I try to load the tar file with wget -c url , I get denied permission.

I can upload the tar file into the project folder but then I have no clue how to find the file via the terminal.

Is there another way I can try?

There is not gcc distribution and sudo permission in MS Jupyter notebook, so you will get the error as the figure below when tried to install TA-Lib via pip, because there is not its pre-compiled wheel file for installation in its PyPI page and the talib Python package requires gcc for compiling the TA-Lib source codes in C.

在此处输入图片说明

在此处输入图片说明

So the solution is to compile and package the talib library as a wheel file from source code manually, then to upload and install it with its dependencies to Microsoft Azure Notebook, finally you can make the sample code works as the figure below.

在此处输入图片说明

Here is my steps in details, I did it in the WSL of my local Windows machine. You can try to do the same in a Linux machine

  1. To create a new directory and init it with virtualenv in Python 3.6

    在此处输入图片说明

  2. Follow the README.md content of mrjbq7/ta-lib to install the TA-Lib C source codes as the dependencies of TA-Lib Python package. It required gcc , make installed in Linux first.

    在此处输入图片说明

  3. Download the source codes of mrjbq7/ta-lib from its releases page, then to decompress and compile it as the commands below.

    在此处输入图片说明

     $ tar -xzf TA_Lib-0.4.17.tar.gz $ cd ta-lib-TA_Lib-0.4.17 $ pip install numpy $ make $ pip wheel --wheel-dir=talib ta-lib $ cd talib
  4. After do Step 3 successfully, there is a file named TA_Lib-0.4.17-cp36-cp36m-linux_x86_64.whl in the talib directory, as the figure below.

    在此处输入图片说明

  5. IMPORTANT : TA-Lib requires a runtime lib named libta_lib.so.0 compiled from Step 3, that you can find it in the path /usr/lib and its real file be named libta_lib.so.0.0.0 , so you need to copy libta_lib.so.0.0.0 and rename it with libta_lib.so.0 .

    在此处输入图片说明

  6. Upload the files TA_Lib-0.4.17-cp36-cp36m-linux_x86_64.whl and libta_lib.so.0 of Step 4 & 5 to your project in MS Azure Notebook, as the figure below.

    在此处输入图片说明

  7. Finally, you can install TA-Lib from your own wheel file and run it successfully.

    在此处输入图片说明

thanks for the extensive answer. After some back and forth i managed to compile something that looks similar to your wheel file. I used the win10 ubuntu terminal and that had its own issue with all sorts of dependencies missing by default.

Anyway it looks now like i compiled the .whl file under python 2.7 which the Azure environment doesn't accept, although im pretty sure that i upgraded the ubuntu python version to 3.6

!pip install TA_Lib-0.4.17-cp27-cp27mu-linux_x86_64.whl

ERROR: TA_Lib-0.4.17-cp27-cp27mu-linux_x86_64.whl is not a supported wheel on this platform.

Since i have to probably repeat the process, some detail questions:

1) What do I need the virtualenv for in step one? My ubuntu distro should already be setup with python right?

2) Do i need step 2 and 3? to my untrained eye it looks like step 3 is just step 2 with and updated tar file.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM