6

Problem: the package I want to install is outdated on pip, and conda doesn't have it in the repo. So, when I install a python package from github using,

git clone package_url 
cd package_name
python setup.py

should I DOWNLOAD the package from within the directory that is the directory in which conda or pip usually would install my package? For example, should I run git clone from within:

['/Users/home/anaconda/lib/python2.7/site-packages',
'/Users/home/anaconda/lib/site-python']

OR, can I just run git clone, from whatever directory I happen to be in.

The concern is that I download from git in something like, /Users/home/Downloads, and then, when I run the setup.py file, I would only install within the /Users/home/Downloads directory, and then when I import, I wouldn't be able to find the package.

Accepted answer: I can run the git clone command in terminal from within any directory. Then, I can change directory into the newly established directory for the package that I cloned, and run the setup.py script. Running the setup.py script should "automatically install [the package] within the site-packages of whatever python [is being] used when python [is invoked]". I hope this helps someone overly anxious about running setup.py files.

4
  • 2
    You typically would run it from within the folder that contains setup.py
    – Suever
    Jul 25, 2016 at 12:18
  • Shoot, I was not clear. I edited my question to reflect the clarity.
    – dnck
    Jul 25, 2016 at 12:35
  • It automatically installs within the site-packages of whatever python you use when you call python setup.py install
    – Suever
    Jul 25, 2016 at 12:41
  • It appears that Suever has answered the concern. I can run the git clone command from within any directory. Then, I change directory into the newly established directory, and run the setup.py script AND the package will be "automatically install[ed] within the site-packages of whatever python [i] use when [I] call python". Thanks!
    – dnck
    Jul 25, 2016 at 12:53

3 Answers 3

3

Run it from the folder containing setup.py.

Doing:

python setup.py install

Will install the package in the appropriate directory. The file already contains the logic that puts the package in the right installation directory, so you don't need to worry about how the package make its way to its installation directory.

6
  • Ah, is this the correct answer then? I don't have to worry about changing into the appropriate subdirectory when I run git clone package_url? I was concerned that the setup would take place only from within the directory that I cloned into...
    – dnck
    Jul 25, 2016 at 12:39
  • You have to be in the directory that contains setup.py to run this. cd into that directory Jul 25, 2016 at 12:40
  • I am very sorry again, because I was totally unclear in my question. I am asking about where to run the git clone package_url command, not the setup.py command. It's obvious to me that I need to be within the folder that contains setup.py to run the program.
    – dnck
    Jul 25, 2016 at 12:51
  • Ah, there isn't any specs relating to that. You can use any folder of your choice, the cloning will however create its own folder in wherever you run the command Jul 25, 2016 at 12:52
  • So, now that I cloned into a folder, and ran the setup.py within the new folder, the setup.py file copies from one directory to a newly established directory. This seems like an inelegant way to do things. Can I safely remove the original cloned copy?
    – dnck
    Jul 25, 2016 at 13:33
1

It can be simpler to use pip for this package as well, by pointing pip directly at the URL:

pip install git+http://....git

The git+ in front of the URL is required.

You can even go a step further and install a specific branch:

pip install git+http://....git@branchname
0

You can run the setup.py file as you stated, and you follow it by install as follow:

python setup.py install

Usually, this would lead to installing the package you want to the python path.

2
  • So, should I worry at all about being in a specific directory when running the git clone package_url command?
    – dnck
    Jul 25, 2016 at 12:38
  • No, you do not have to do do that, just run setup.py in that way and it will be fine
    – mase_cv_ml
    Jul 26, 2016 at 13:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.