Conda setuptools install changes shebangs to default python install

Conda setuptools install changes shebangs to default python install

Ask Question

up vote 2 down vote favorite

https://stackoverflow.com/questions/39255544/conda-setuptools-install-changes-shebangs-to-default-python-install

I'm having an issue where packages installed via setuptools to python anaconda have shebangs rewritten to the wrong location.

I have installed python anaconda and setuptools package. I have verified that python executable points to the anaconda executable

grant@DevBox2:/opt/content-analysis$ which python
/opt/anaconda2/bin/python

I need to install a custom package to my anaconda python. It is only installable via setuptools. It includes an command-line executable with the following shebang at the top:

#!/usr/bin/env python

After installing the package with the following command:

sudo python setup.py install --prefix=/opt/anaconda2

The executable (content_analysis) appears in a path reachable location. But the shebang at the top has been replaced with the hard coded location of the default python install on the machine.

grant@DevBox2:/opt/content-analysis$ which content_analysis
/opt/anaconda2/bin/content_analysis
grant@DevBox2:/opt/content-analysis$ sed -n 1,2p /opt/anaconda2/bin/content_analysis 
#!/usr/local/bin/python

I have read the following post here concerning setuptools' overwrite of shebangs. The post suggests that the python executable that is first in the $PATH should be the executable that setuptools uses to replace the shebang. This doesn't seem to be the case for me however.

Note: I cannot hardcode a python executable into my python setup.py build command. I need a deployment solution that will work in any environment that has conda installed as the first python in the $PATH

python anaconda setuptools conda

shareimprove this question

edited May 23 '17 at 11:54

Community

11

asked Aug 31 '16 at 17:23

GrantD71

650719

add a comment

1 Answer

active oldest votes

up vote 2 down vote accepted

I finally figured out what has been causing all my issues getting python and dependencies properly installed:

Whenever sudo is invoked before an executable, in Debian the $PATH variable is automatically changed to a secure path lookup. Here is a demonstration:

grant@DevBox2:/opt/content-analysis$ sudo sh
# echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin

versus

grant@DevBox2:/opt/content-analysis$ sh
$ echo $PATH
/opt/anaconda2/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games

So, when sudo is invoked prior to sudo python setup.py the install is reverting back to the default python.

See this post for discussion

shareimprove this answer

edited Apr 13 '17 at 12:36

Community

11

answered Aug 31 '16 at 19:02

GrantD71

650719

add a comment

Your Answer

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值