Pip install forked github-repo - python

I'm working on a project and need a little different functionality from the package sklearn. I've forked the repo and pushed my changes. I know that I can install from github via pip:
pip install git+git://github.com/wdonahoe/scikit-learn-fork.git#master
and then I can install the package with setup.py:
python setup.py install
However, I am confused about what to do after this step. Running setup.py creates some .egg-info folders and .egg-links files in .../dist-packages/, but I am unsure what to do with them. Ideally, I'd like to go into my project in .../projects/my_project and say something like
from sklearn-my-version import <stuff>
or switch it out with just
from sklearn import <stuff>
I am also a little confused because a lot of resources on this issue mention using easy_install, which I thought pip replaced.

try again using just (-e flag lets you git pull updates by installing it as a git repo)
pip install -e git+git://github.com/wdonahoe/scikit-learn-fork.git#master#egg=scikit-learn
more on eggs:
http://mrtopf.de/blog/en/a-small-introduction-to-python-eggs/

Related

Editing a python package

The question is really simple:
I have a python package installed using pip3 and I'd like to tweak it a little to perform some computations. I've read (and it seems logical) that is very discouraged to not to edit the installed modules. Thus, how can I do this once I downloaded the whole project folder to my computer? Is there any way to, once edited this source code install it with another name? How can I avoid mixing things up?
Thanks!
You can install the package from its source code, instead of PyPi.
Download the source code - do a git clone <package-git-url> of the package
Instead of pip install <package>, install with pip install -e <package-directory-path>
Change code in the source code, and it will be picked up automatically.

How to install a python program using setup.py

I am trying to install labelImg using setup.py. I run the command:
sudo python3 setup.py install
to install it and everything seemed to be fine. Unfortunately when I tried to execute the program (just tried labelImg &) got an import error:
ImportError: No module named 'resources'
So, I was wondering if I did something wrong or if there something I could do to fix it. My first thought is to provide an absolute import path to resources (and to the following libs imports) but that does not seem the right thing to do. Also it might work for a small project but it's obvious out of reach for a big one.
The git repo seem to imply that I should run it via python, but why then a setup.py exists?
I know I can use the program via python or even install it via PyPI but I am not interested in that.
The labelImg project depends on other libraries to work such as pyqt5-dev-tools and lxml.
If you check their documentation, first you have to install pyqt5-dev-tools:
sudo apt-get install pyqt5-dev-tools
Then install lxml:
sudo pip3 install lxml
After that you have to run the make command in order to build the pyqt5-dev-tools library so that the python code can use it properly (make is used to build executable libraries and programs from source code):
make qt5py3
And finally you can run python3 labelImg.py and use labelImg.

What's the difference between direct pip install and the requirements.txt?

I'm confused. I've got a working pip install command (meaning: it installs a version of a library from Github which works for me), and I have a non-working (meaning: it installs a version of a library which does not work for me) way of putting that requirement into a requirements.txt file.
More concrete:
If I type on the command line
pip install -e 'git://github.com/mozilla/elasticutils.git#egg=elasticutils'
and then test my program, all works fine. If I put this line into my requirements.txt:
-e git://github.com/mozilla/elasticutils.git#egg=elasticutils
and then run my program, it breaks with an error (only the library should have changed, so I guess sth has changed in that library between the two versions).
But shouldn't both versions do exactly the same?? (Of course I've done my best to remove the installed version of the library between the two tests again, using pip uninstall elasticutils.)
Any information welcome …
Yep, as I wrote in my comment above, there seems to be a dependency-override when the requirements.txt states different than the dependencies in the packages. In my case installing the package manually also installed the (newer) version of requests, namely 1.2.0. Using the requirements.txt always installed (due to the override) the version 0.14.2 of requests.
Problem solved by updating the requests version in the requirements.txt :-)
Well I don't know exactly what's the difference, but when I want something to be installed from the requirements.txt and it's a git repo I do the following line:
#git+https://github.com/user/package_name.git
and then installing as following:
pip install -r requirements.txt

How to install many python extensions in one step

Is it possible to collect many Python extensions an install them in one step? I have a Python build environment for an open source project that often needs to be recreated on multiple machine. It's a pain to double click through a bunch of python extension exes every time we need to do this.
Ideally I'd like to package a complete build environment, Python, extensions, system environment variables, and all, into a one step install process. But a single step extension install would also be helpful. Is this possible?
Yes, you can do that... do you have pip(python indexed package) installed in your system?
if not, then install it... and put all the extensions into a single text file... say requirements.txt...
This is done by running
pip freeze > requirements.txt
then by using pip you can install it... by using this command...
pip install -r requirements.txt...
it will install all the extensions mentioned in the file...
you can find the pip package here pip
might help you...
You can with Distribute define dependencies of a package, and easy_install or pip will install all dependencies when you ask to install the package.

Using pip to install single-file python modules

I'm wondering if there's a way to "install" single-file python modules using pip (i.e. just have pip download the specified version of the file and copy it to site-packages).
I have a Django project that uses several 3rd-party modules which aren't proper distributions (django-thumbs and a couple others) and I want to pip freeze everything so the project can be easily installed elsewhere. I've tried just doing
pip install git+https://github.com/path/to/file.git
(and tried with the -e tag too) but pip complains that there's no setup.py file.
Edit: I should have mentioned - the reason I want to do this is so I can include the required module in a requirements.txt file, to make setting up the project on a new machine or new virtualenv easier.
pip requires a valid setup.py to install a python package. By definition every python package has a setup.py... What you are trying to install isn't a package but rather a single file module... what's wrong with doing something like:
git clone git+https://github.com/path/to/file.git /path/to/python/install/lib
I don't quite understand the logic behind wanting to install something that isn't a package with a package manager...

Categories

Resources