Use package from Github in Conda Virtual Environment - python

Setup
Conda virtual environment
Coding in a Jupyter notebook
Python version 3.6
I have Googled, searched through the Conda help, github help on this site as wel as found closely relevant questions, that just don't answer mine:
Conda install package from github including requirements.txt
Conda: installing local development package into single conda environment
That first one comes close though.
Basically my question comes down to:
For my code to work i need to import this repo: https://github.com/nicocanali/airtable-python
How can I get this to be used in my Jupyter Notebook?
I'll need to add it to my virtual environment. But how?

I ended up doing the following:
Install git in the virtual environment: (conda install git)
Clone the project. (git clone [URL])
Install the package (cd to package directory that contains setup.py.
Then run "python setup.py install").
Found the answer in the first part in this video: How to Install Python Package from GitHub

To install https://github.com/nicocanali/airtable-python to your jupyter.
Download the .zip of the repo from the github website.
To install it in jupyter enter the following command from the anaconda console.
pip install [path_to_.zip_file_on_pc]
Works on any github file

Found a simple solution here:
https://medium.com/i-want-to-be-the-very-best/installing-packages-from-github-with-conda-commands-ebf10de396f4
For example, to install the package located at
https://github.com/Netflix/metaflow, navigate to your desired environment in the Anaconda prompt, activate the environment, and then execute the following commands:
conda install git
conda install pip
pip install git+git://github.com/Netflix/metaflow.git
(Note that the git package is available in Anaconda Navigator, so can be installed from there instead of from the Anaconda prompt.)

Related

Installing cusignal on windows 10

I wanted to install the cusignal python package on windows and I was following the instructions on the following github link.
It says to run the following commands:
conda create --name cusignal-dev
conda activate cusignal-dev
conda install numpy numba scipy cudatoolkit pip
pip install cupy-cuda101
cd python
python setup.py install
But towards the last two lines, I have no idea what and where the setup.py file is located. There is also no such folder called python that is automatically created. Hence, I am unsure how I am supposed to install cusignal library on windows 10.
The instructions expect that you first clone the GitHub repository, which has such a python folder, then run those instructions, like
git clone https://github.com/rapidsai/cusignal.git
cd python
python setup.py install
Be sure your environment is activated when doing this.

ModuleNotFoundError or ImportError When Installing Python Packages to Conda Env That Require Pip

While this may be pretty straightforward, I want to share a solution to an issue I was having since I did not have a problem with this until now.
Essentially I was having trouble running splinter in my conda virtual environment. I first activated my environment conda activate PythonData. Then I tried to run conda install splinter which failed, then conda install -c metaperl splinter which also failed.
I then moved onto using pip, so I went to the documentation and ran pip install splinter.
The installation said it was successful, but after restarting the kernel I was still receiving the same error.
See below the solution :)
I looked through my anaconda bins and did not find the package. Then I realized when I try to install a second time (after ensuring my environment was indeed activated), I saw it was installed in my usr folder - not my anaconda3 folder.
Therefore, I had to run pip uninstall splinter to remove it, and then did the following:
conda install pip to first install pip (which I used previously with no errors so this is puzzling, but such is life)
conda info to find my active environment path
After copying the active environment path similar to the following /anaconda/envs/venv_name, I was able to run the installation like this:
/anaconda/envs/venv_name/bin/pip install splinter
And then viola! It worked.

Installing python packages on anaconda on macos

This may be a silly simple question, but I couldn't find an answer in the documentation of Anaconda or elsewhere. I am a bit of a noob when it comes to Python and I am trying to install a package. The problem is generalizable to other packages.
specs
I am working on a macOS Catalina (10.15.5) and using Anaconda as my python environment (python2.7).
problem
I am attempting to install the package pyLDAvis in my python environment, but the package isn't available on Anaconda's environment manager, and pip or conda install isn't working on the Spyder shell. Do pip and conda installs only work on the Anaconda Prompt? The problem is that I have read that the Anaconda Prompt only exists on Windows, and I am on mac. How could I install packages (pip, conda, or else) on Anaconda?
Am I missing something?
Any help or pointers to documentation would be great! Thanks
Assuming you have conda already installed and your shell is properly configured, you can activate the base environment via
conda activate
You can also create a new environment, see manage-environments docs.
For more information than given below, see manage-pkgs docs.
In case of conda, after your environment is activated, you can then install a package via conda install <package name>, e.g. the package numpy
conda install numpy
In case of pip, after your environment is activated, you can then install a package via pip install <package name>, e.g. the package numpy
pip install numpy
I only do this if the package is not available via a conda channel.
If the package is also not available via pip, you can download the source and set the package up your self. Usually the package author describes how to set up his/her package.
Thanks Stefan for the suggestion! I struggled a bit because although conda was "already installed", my shell was indeed not "properly configured." I am writing here my solution because it may be a recurring theme for macOS users and had an easy fix.
Starting with macOS Catalina, macOS uses zsh and not bash as the default shell, and so calling conda on zsh had no effect. The error message was: -zsh: conda: command not found. I solved this by changing the default shell to bash by running the following command: chsh -s /bin/bash.
Now that the shell and conda are properly configured, I managed to use conda activate as you suggested Stefan.
Finally, the package pyLDAvis could not be installed by conda install pyldavis but was installed with pip install pyldavis.
Solved!

How to use egg to install scikit-image?

I am stuck on this installation of scikit-image (aka skimage). I tried multiple ways:
Installation from a git hub folder (using the requirements.txt)
Installation from a whl file
Installation with pip install scikit-image
All three trials failed during the import: import skimage
ImportError: cannot import name 'geometry'
It seems that scikit-image has not been built correctly.
Your install of scikit-image appears to be broken.
Try re-installing the package following the instructions at:
https://scikit-image.org/docs/stable/install.html
I went through internet but did not find solutions besides the ones above.
Does anyone went through that before?
One possibility seems to be to pip install with -egg, but I found that for Mac rather than Windows.
EDIT:
Hi everyone, so I found a solution but this is kind of very hard and I still don't understand why it did not work before.
I just:
uninstall anaconda
uninstall python
install python (3.8)
install Anaconda (I have trouble with Spyder now^^)
If you want to code for computer vision/Image processing/machine learning tasks, then it can be done in pycharm with conda environment very easily. There is no need to install python separately to run Anaconda.
First, download and install pycharm. Next, If you use windows then download Anaconda 64 bit python 3.7 version from here,
https://www.anaconda.com/distribution/#windows
You can find some details about managing environment and helpful links here,
How to create some environments for tensorflow in anaconda?
https://docs.conda.io/projects/conda/en/latest/user-guide/tasks/manage-environments.html
Create a conda environment first using Anaconda Prompt command line,
conda create -n cvenv python=3.7
Now activate that environment using. By default base is activated.
conda activate cvenv
Next, install the packages you want,
conda install -c conda-forge scikit-learn
conda install -c conda-forge scikit-image
conda install -c conda-forge pillow
conda install -c conda-forge opencv
I use conda-forge packages as they are more recent. Finally, open pycharm and create a new project by selecting existing python interpreter in conda environment. If none exists then select,
Browse > Add Python Interpreter > Conda Environment > Interpreter > Browse > Anaconda3 installation folder > envs folder > cvenv folder > Python.exe
You can test by creating a python file and writing import skimage.

Install python packages to correct anaconda environment

I've setup anaconda and created a python 3.3 environment. Now I wanted to install some package (dataset). The install instructions ask to clone the git repo and run
python setup.py install
but now the packages are not installed to the environments site-packages folder but to a different anaconda location.
What are the normal steps to solve that problem? Newbie-compatible solutions are preferred. The OS is MacOSX, just is case, it is relevant.
It looks like conda automatically adds pip to your conda environment, so after you source your conda environment, i.e.:
source activate ~/anaconda/envs/dataset
you should be able to install it like this:
git clone git://github.com/pudo/dataset.git
pip install ./dataset
EDIT
Here are the exact steps I took:
$ conda create -p ~/anaconda/envs/py33 python=3.3 anaconda pip
$ source activate ~/anaconda/envs/py33
$ which pip
~/anaconda/envs/py33/bin/pip
$ pip install ./dataset/

Categories

Resources