How can I use jython setup.py install?

2019-02-20 15:54发布

问题:

I am using a Jython virtualenv where I can install whatever software via pip or via easy_install, but there is a software that is not registered yet and the installation mode via:

[sudo] python setup.py install 

and I am trying to do the same with jython:

[sudo] jython setup.py install

So, I am getting these follow errors:

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

I checked and installed jython ez_setup.py again. I downloaded the yolk and didn't solved too.

My folder:

╭─hudson@hudson-pc ~/jython2.7a1/Lib/site-packages ‹› ‹master*›
╰─$ ls 
easy-install.pth         setuptools.pth yolk 0.4.3-py2.7.egg README should_dsl-2.0a5-py2.7.egg setuptools-0.6c11-py2.7.egg virtualenv-1.7.2-py2.7.egg 

And at the normal(real) environment, without virtualenvs, I got the same erros.

At Python I already installed this software and worked well.

If I enter at Jython Shell and try import setuptools, I got the same erros too:

>>> import setuptools
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named setuptools
>>> import sys
>>> sys.path
['', '/home/hudson/jython2.7a1/Lib', '/home/hudson/__classpath__',   '/home/hudson/__pyclasspath__']

Then, I add the site-packages to the sys (It can be a stupid attempt):

>>> sys.path.append('/home/hudson/jython2.7a1/Lib/site-packages')    
>>> sys.path
['', '/home/hudson/jython2.7a1/Lib', '/home/hudson/__classpath__', '/home/hudson/__pyclasspath__', '/home/hudson/jython2.7a1/Lib/site-packages']  
>>> import setuptools
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named setuptools

Why is not recognizing?

回答1:

If pip "works" then you could use it to install your software. To try it, run from a directory with setup.py:

$ pip install -e .

If you have a tarball of the package:

$ pip install your_package-0.0.1.tar.gz

pip can install from a git repository, use custom urls from where to get packages, etc.

I've tested it: jython works with virtualenv, distribute (a fork of setuptools), pip. So jython can install a package if it uses setuptools in setup.py.



回答2:

Basically you need to install the installtool first. To do so see the doc linked below.

install this: http://peak.telecommunity.com/dist/ez_setup.py

(see here:http://www.jython.org/jythonbook/en/1.0/appendixA.html#setuptools)