How to install spoonacular python package - python

I'm trying to use the spoonacular python API found here https://github.com/ddsky/spoonacular-api-clients/tree/master/python
However, I can't seem to figure out how to install it in a virtualenv. I'm used to installing packages using pip. So when the instructions say to install like this:
pip install git+https://github.com/GIT_USER_ID/GIT_REPO_ID.git
do I need to save this directory (https://github.com/ddsky/spoonacular-api-clients/tree/master/python) to my own GitHub repo?
Any help would be greatly appreciated!

You're right something is strange, I tried a more direct approach:
First activate your virtual environment
Clone repo : git clone https://github.com/ddsky/spoonacular-api-clients.git
Install the package manually:
$ cd spoonacular-api-clients/python
$ python setup.py install
It should work:

Related

What is the use of `pip install -e .` if I can simply run the python script using the environment?

Based on this answer, I can fully understand the use of:
pip install -e /path/to/locations/repo
However, I am yet to see the use of:
pip install -e .
I can understand it from the perspective of doing pip install -e /path/to/locations/repo, but from the working directory of the project dependency. But that's the only use case I can see.
In what use case would I want to install locally the same package I am now working on?
pip install -e
will just create a projekt_name.egg-info file in the venv\Lib\site-packages folder with a link to the repo location. Nothing is copied.
You can continue developing and you can access your project packages as if the repo was properly installed. No dirty sys.path.append-hacks needed.

How to pip freeze source package

I am learning how to use venv here: https://packaging.python.org/guides/installing-using-pip-and-virtual-environments/#installing-from-source
And it says I can install a source package by:
python3 -m pip install .
Which works, but now if I do pip freeze then I see:
my-package # file:///Users/joesmith/my-package
The problem is if I export this to a requirements.txt and try to install this environment on another machine then it won't work cause the path to source changed obviously.
What is the proper way to use a source package locally like i did but also export it afterwards so that another person can recreate the environment/run the code on another machine?
Pip has support for VCS like git. You can upload your code to git (e.g. Github, Gitlab, ..) for example and then use the requirements.txt. like this:
git+http://git.example.com/MyProject#egg=MyProject
https://pip.pypa.io/en/stable/cli/pip_install/#vcs-support
You would install package from PyPI rather than from source.
i.e. pip install requests
In this way other developers will also easily run your project.

Can't install python package available on github

I am trying to install a python package that is available on github, but am unsure how to do so. This is the package: https://github.com/Jefferson-Henrique/GetOldTweets-python.
Could someone please provide me clear and step-by-step instructions on how to do this installation? None of the current answers are clear enough for me. I have tried the following command prompt command, but it is not working. I have git installed.
pip install git+https://github.com/Jefferson-Henrique/GetOldTweets-python.git
Error:
Cloning https://github.com/Jefferson-Henrique/GetOldTweets-python.git to c:\users\haris\appdata\local\temp\pip-ocsu8r-build
Error [Error 2] The system cannot find the file specified while executing command git clone -q https://github.com/Jefferson-Henrique/GetOldTweets-python.git c:\users\haris\appdata\local\temp\pip-ocsu8r-build
Cannot find command 'git'
git isn't installed via pip. It's a regular package that you'll want to install by doing apt install git, most likely as root.
You’ll need to install the package outside of pip since it’s not a python package. Conda install will work if you have anaconda or miniconda , or apt get install if you’re on a Linux system. Once you have git, run got clone package_name after navigating to the desired directory and you should be good to go.

'bz2 is module not available' when installing Pandas with pip in python virtual environment

I am going through this post Numpy, Scipy, and Pandas - Oh My!, installing some python packages, but got stuck at the line for installing Pandas:
pip install -e git+https://github.com/pydata/pandas#egg=pandas
I changed 'wesm' to 'pydata' for the latest version, and the only other difference to the post is that I'm using pythonbrew.
I found this post, related to the error, but where is the Makefile for bz2 mentioned in the answer? Is there another way to resolve this problem?
Any help would be much appreciated. Thanks.
You need to build python with BZIP2 support.
Install the following package before building python:
Red Hat/Fedora/CentOS: yum install bzip2-devel
Debian/Ubuntu: sudo apt-get install libbz2-dev
Extract python tarball. Then
configure;
make;
make install
Install pip using the new python.
Alternative:
Install a binary python distribution using yum or apt, that was build with BZIP2 support.
See also: ImportError: No module named bz2 for Python 2.7.2
I spent a lot of time on the internet and got a partial answer everywhere. Here is what you need to do to make it work. Follow every step.
sudo apt-get install libbz2-dev Thanks to Freek Wiekmeijer for this.
Now you also need to build python with bz2. Previously installed python won't work. For that do following:
Download stable python version from https://www.python.org/downloads/source/ then extract that Gzipped source tarball file. You can use wget https://python-tar-file-link.tgz to download and tar -xvzf python-tar-file.tgz to extract it in current directory
Go inside extracted folder then run following commands one at a time
./configure
make
make install
This will build a python file with bz2 that you previously installed
Since this python doesn't have pip installed, idea was to create a virtual environment with above-built python then install pandas using previously installed pip
You will see python file in the same directory. Just create a virtual environment.
./python -m env myenv (create myenv in the same directory or outside it's your choice)
source myenv/bin/activate (activate virtual environment)
pip install pandas (install pandas in the current environment)
That's it. Now with this environment, you should be able to use pandas without error.
pyenv
I noticed that installing Python using source takes a long time (I am doing it on i7 :/ ); especially the make and make test...
A simpler and shorter solution was to install another version of Python (I did Python 3.7.8) using pyenv, install it using these steps.
It not only saved the problem of using multiple Python instances on the same system but also maintain my virtual environments without virtualenvwrapper (which turned buggy on my newly setup ubuntu-20.04).

Correct way to integrate a Python module into my code (Hg, Google Code)

I had a custom script programmed and it is using the authors own module that is hosted on Google code in a Mercurial repo. I understand how to clone the repo but this will just stick the source into a folder on my computer. Is there a proper way to add the module into my python install to make it available for my projects? (e.g. with modules hosted on pypi you can use virtualenv and pip to install).
Thanks
Dave O
In exactly the same way. Just pass the address of the repo to pip install, using the -e parameter:
pip install -e hg+http://code.google.com/path/to/repo
If the module isn't on pypi, clone the repository with Hg and see if there's a setup.py file. If there is, open a command prompt, cd to that directory, and run:
python setup.py install

Categories