import from github repository into Python jupyter notebook - python-3.x

Goal: I want to import this library https://github.com/Kaggle/learntools into a jupyternotebook so that I can use use both the following packages:
from learntools.core import binder
from learntools.machine_learning.ex8 import *
To do this, I tried to two methods to clone the github library with this command.
1st method:
conda install git
pip install auto-py-to-exe
pip install git+https://github.com/Kaggle/learntools.git
2nd method:
%%bash
git clone https://github.com/Kaggle/learntools
Situation/Problem:
1st method gave this error:
WARNING: Discarding git+https://github.com/Kaggle/learntools.git. Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
2nd method gave this error:
bash: line 1: git: command not found
Question: How can I clone/import this github library https://github.com/Kaggle/learntools into my jupyter notebook so that I can use its packages in the code.
Thank you for taking your time in answering it.
Seems like a really basic step to do, but somehow is not working on my side.

First method
Can't really do much for you since you haven't provided the full log output.
Second method
It looks like you've installed git in your conda environment, but not to your machine as a whole. I believe the instance of bash that is being used for your second method is not using your conda environment. You didn't share your conda environment's name, but if we assume it's gitenv, You could try this:
conda activate gitenv && git clone https://github.com/Kaggle/learntools
However, I'd recommend that you simply install git for your whole machine. I can't think of any reason to have it installed only in a conda environment.
Once you have the repo cloned, you'll have to use pip to install it as a package.

Related

Install geopandas in Pycharm

Sorry if this is a repeat question, But I am new to Python and trying to install Geopandas in Pycharm.
My python version is 3.7.2.
I have tried the conventional way of installing library in pycharm through project interpretor.
I have also tried pip install geopandas
Both show same error.
A GDAL API version must be specified. Provide a path to gdal-config using a GDAL_CONFIG environment variable or use a GDAL_VERSION environment variable.
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output
Please provide steps to follow wrt Pycharm if possible.
According to Geopandas's own install instructions, the recommended way is to install via conda package manager, which you can obtain by using the Anaconda or miniconda Python distributions:
conda install geopandas
If, however, you have a Very Good Reason you can't use conda, and absolutely need to use pip, you should try installing GDAL first (pip install GDAL), and then checking if the gdal-config command is in your path (i.e. that you can access it via the terminal). Then you can try installing again from either PyCharm directly or via the command line.
If you can't get it installed from PyCharm and need to specify GDAL_VERSION (which you can get with gdal-config --version), you'll probably need to install from the command line, where you can set this variable either with an export or directly in the same invocation:
GDAL_VERSION=2.4.2 pip install geopandas

Running Ludwig on AML Compute: docker image failing to build on gmpy

I'm currently trying to create a TensorFlow estimator to run Ludwig's training model on Azure ML Compute with various pip and conda packages like so:
estimator= TensorFlow(source_directory= project_folder,
compute_target=compute_target, script_params=script_params,
entry_script='./train.py', pip_packages=dependencies, conda_packages =
["tensorflow"], use_gpu =True)
One of the pip packages is gmpy, but it will not install and throws an error: fatal error: gmp.h: No such file or directory compilation terminated. error: command 'gcc' failed with exit status 1.
This prevents Ludwig from installing and causes the imagine to fail to build
When I run Ludwig locally in a python virtual environment on Ubuntu, I'm able to work around this issue by running “sudo apt-get install libgmp3-dev” instead of pip install gmpy. When I try adding Gmpy2 as a library to the estimator, it throws the same error, and it seems that libgmp3-dev doesn't have a pip or conda equivalent. I tried adding the gmpy and gmpy2 .whl files directly to the environment but the wheel files were not recognized as compatible.
Is there some way to add RUN sudo apt-get install libgmp3-dev to the dockerfile so that the docker container made by the estimator has this already installed without needing to create a custom dockerfile? I noticed that the TensorFlow estimator class has an "environment_definition" flag that can take a DockerSection but I can't find any examples of how they work.
Looks like they have gmpy2 on conda-forge channel
https://anaconda.org/conda-forge/gmpy2
you can also should be able to reference dependency from # git

Unable to install git repo by pip

I am trying to install a git repo's master branch source by pip and I am using the command
pip install git+https://github.com/apache/systemml/#master#egg=systemml&subdirectory=src/main/python
But I encountered the error:
Command "python setup.py egg_info" failed with error code 1 in
C:\Users\test\AppData\Local\Temp\pip-install-3hqjwj06\systemml\
'subdirectory' is not recognized as an internal or external command,
operable program or batch file.
So I researched about it and found the StackOverFlow
question and followed the following steps of the most upvoted answer but it didn't work in my case. I also tried installing python 3.6 and it also did not help.
I am using Windows OS and 3.7 python
Any help is appreciated.

installation of assimulo and sundials - error

I want to use Assimulo and Sundials for the solution of differential algebraic equations in Python and therefore I am trying to install it on Ubuntu.
For the installation of Sundials, I followed the installation instructions and as I understand it worked well.
% cmake -DCMAKE_INSTALL_PREFIX=/usr/local/lib/sundials-3.1.1/ ~/opt/sundials/sundials-3.1.1
% make
% make install
Then I tried to install Assimulo with the command pip3 install Assimulo, but I get an error message. I also tried to follow the instructions on Installation - Assimulo 3.0 documentation by downloading the installation files and install it with the following command. It results in the same error message.
sudo python3 setup.py install --sundials-home=/usr/local/lib/sundials-3.1.1
This is the error message I get:
target build/src.linux-x86_64-3.6/assimulo/thirdparty/hairer/dopri5module.c does not exist:
Assuming dopri5module.c was generated with "build_src --inplace" command.
error: 'assimulo/thirdparty/hairer/dopri5module.c' missing
What is wrong and how can I fix it? Any help would be appreciated!
I got the same error when installing on macos via pip install assimulo, after pip-installing numpy and cython.
For me, using a conda env did the trick:
Creating the conda env: conda create -n your_name_goes_here
conda activate your_name_goes_here
conda install python=3.6 (I noticed you can also use 3.7)
conda install -c conda-forge assimulo
I also had the same error message. As suggested in the other answer, you can get a compiled package from Conda. But if you want to compile from source yourself, it looks to me that PyPI source tarball doesn't contain all needed files. At least some *.pyf files are missing. So, I used SVN repo instead:
svn checkout https://svn.jmodelica.org/assimulo/tags/Assimulo-3.0/ assimulo
By compiling this source tree, I managed to get pass the original error you had, but I'm now having another build error that I don't know yet how to solve:
ssimulo/solvers/sundials.c: In function '__pyx_f_8assimulo_7solvers_8sundials_5CVode_initialize_cvode':
assimulo/solvers/sundials.c:33274:31: error: too many arguments to function 'CVodeCreate'
__pyx_v_self->cvode_mem = CVodeCreate(__pyx_t_3, __pyx_t_4);

Making setup.py to point to local pypi repository

recently i found pip2pi, which is super useful to install pip package from local pypi repo. I just followed the post here to do that http://blog.nknj.me/python-guide-to-hacking-on-an-airplane
But when I use setup tools, requires, I do not know how I can make it to use my local repo. I do not want to download the packages each time when i run "python setup.py develop". I am getting started with pyramid, and it will be helpful if i can avoid downloading packages everytime i create a new virtualenv.
Thanks in advance
Here is workaround:
$ python setup.py egg_info
The command above creates a directory {PackageName}.egg-info and places requires.txt file into one, but downloads nothing. So you can use requires.txt file with pip command to install dependencies:
$ pip install -r {PackageName}.egg-info/requires.txt --index-url=file:///path/to/local/repo
After that, you can install your application without access to the internet:
$ python setup.py develop

Resources