简体   繁体   English

如何从Github安装没有root访问权限的python模块?

[英]How to install a python module from Github with no root access?

I've read several article but I've had no luck as my situation conflicts with one or more freedoms that others have. 我读过几篇文章,但是我的运气与他人的一种或多种自由相冲突,因此我没有运气。 This is my situation. 这是我的情况。

  • I've no access to root . 我无法访问root
  • I'm just a user with access to python. 我只是可以访问python的用户。 No sudo . 没有sudo
  • python 2.xx is pre-installed 预先安装了python 2.xx
  • pip is not pre-installed. 未预先安装pip
  • apt-get requires root privileges. apt-get需要root特权。

My goal is to install a simple module called Guessit from Github for my foo.py project. 我的目标是为我的foo.py项目安装一个来自Github的名为Guessit的简单模块。 The installation for it is given by pip so that option is ruled out. 它的安装由pip给出,因此可以排除该选项。 I tried to manually install as per https://github.com/guessit-io/guessit/blob/master/docs/sources.rst . 我试图按照https://github.com/guessit-io/guessit/blob/master/docs/sources.rst进行手动安装。 I downloaded the zip file, extracted it and ran 我下载了zip文件,将其解压缩并运行

python setup.py install

It gives me the following error 它给我以下错误

 Traceback (most recent call last): File "setup.py", line 4, in <module> from setuptools import setup, find_packages ImportError: No module named setuptool 

So, at this point I reckoned I needed setuptools module and hence downloaded https://bootstrap.pypa.io/ez_setup.py and tried to install it as per https://pypi.python.org/pypi/setuptools by running 因此,在这一点上,我认为我需要setuptools模块,因此下载了https://bootstrap.pypa.io/ez_setup.py并尝试通过运行按照https://pypi.python.org/pypi/setuptools进行安装

wget https://bootstrap.pypa.io/ez_setup.py -O - | python

Again, it was a failure with an error like this: 同样,这是一次失败,并显示如下错误:

 Downloading https://pypi.io/packages/source/s/setuptools/setuptools-24.0.0.zip Extracting in /tmp/tmplNW7fe Now working in /tmp/tmplNW7fe/setuptools-24.0.0 Installing Setuptools Traceback (most recent call last): File "setup.py", line 21, in <module> exec(init_file.read(), command_ns) File "<string>", line 11, in <module> File "/tmp/tmplNW7fe/setuptools-24.0.0/setuptools/__init__.py", line 14, in <module> from setuptools.extension import Extension File "/tmp/tmplNW7fe/setuptools-24.0.0/setuptools/extension.py", line 11, in <module> from . import msvc File "/tmp/tmplNW7fe/setuptools-24.0.0/setuptools/msvc.py", line 244, in <module> class PlatformInfo: File "/tmp/tmplNW7fe/setuptools-24.0.0/setuptools/msvc.py", line 253, in PlatformInfo current_cpu = safe_env['processor_architecture'].lower() File "/usr/lib/python2.7/UserDict.py", line 23, in __getitem__ raise KeyError(key) KeyError: 'processor_architecture' Something went wrong during the installation. See the error message above. 

Now, I'm guessing there is a match problem with the architecture of that setup and on my machine. 现在,我猜想该设置的体系结构和我的机器上存在匹配问题。

At this point, I'm not even sure if what I'm doing is right anymore. 在这一点上,我什至不确定我正在做的事情是否正确。 For whatever its worth, this is my the computer achitecture using uname -a 无论其价值如何,这都是我使用uname -a的计算机体系结构

 Linux sl04.cmi.ac.in 3.13.0-85-generic #129-Ubuntu SMP Thu Mar 17 20:50:41 UTC 2016 i686 i686 i686 GNU/Linux 

Any help would be greatly appreciated! 任何帮助将不胜感激!

There's a problem in setuptools 24.0.0 (released today). setuptools 24.0.0(今天发布)中存在问题。 I assume it will be fixed soon. 我认为它将很快修复。 Meanwhile, downgrade to 23.1 and reinstall the desired package. 同时,降级到23.1,然后重新安装所需的软件包。

from your description it sounds like you could install setuptools in a user-local path to get over your first hurdle. 根据您的描述,听起来您可以在用户本地路径中安装setuptools来克服第一个障碍。

see: https://pypi.python.org/pypi/setuptools#installation-instructions 参见: https : //pypi.python.org/pypi/setuptools#installation-instructions


but really in a situation like the OP, you would bootstrap pip : 但实际上在OP之类的情况下,您会引导pip

then: 然后:

  • pip install virtualenv

then use an activated virtualenv as a place to install your module. 然后使用激活的virtualenv作为安装模块的位置。

This would keep your module or other dependencies apart from system packages, and doesn't require special privleges. 这将使您的模块或其他依赖项与系统软件包分开,并且不需要特殊的特权。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM