The jython installer installs pip on request at installation time. This used to work, however, this stopped to work some time ago.
Fetch the jython installer over here:
http://search.maven.org/remotecontent?filepath=org/python/jython-installer/2.7.0/jython-installer-2.7.0.jar
Then install using the "silent" install mode to a directory (`jythontest270'):
C:> java -jar jython-installer-2.7.0.jar -s -d jythonpiptest270
The above command craps out with a traceback like:
Traceback (most recent call last):
File "D:\nexiles\jython\Lib\runpy.py", line 161, in _run_module_as_main
return _run_code(code, main_globals, None,
File "D:\nexiles\jython\Lib\runpy.py", line 72, in _run_code
exec code in run_globals
File "D:\nexiles\jython\Lib\ensurepip\__main__.py", line 4, in <module>
ensurepip._main()
File "D:\nexiles\jython\Lib\ensurepip\__init__.py", line 220, in _main
bootstrap(
File "D:\nexiles\jython\Lib\ensurepip\__init__.py", line 123, in bootstrap
_run_pip(args + [p[0] for p in _PROJECTS], additional_paths)
File "D:\nexiles\jython\Lib\ensurepip\__init__.py", line 45, in _run_pip
import pip
File "C:\Users\ADMINI~1\AppData\Local\Temp\1\tmpguetqs\pip-1.6-py2.py3-none-an
y.whl\pip\__init__.py", line 10, in <module>
File "C:\Users\ADMINI~1\AppData\Local\Temp\1\tmpguetqs\pip-1.6-py2.py3-none-an
y.whl\pip\util.py", line 17, in <module>
File "C:\Users\ADMINI~1\AppData\Local\Temp\1\tmpguetqs\pip-1.6-py2.py3-none-an
y.whl\pip\locations.py", line 109, in <module>
File "C:\Users\ADMINI~1\AppData\Local\Temp\1\tmpguetqs\pip-1.6-py2.py3-none-an
y.whl\pip\locations.py", line 90, in _get_build_prefix
AttributeError: 'module' object has no attribute 'geteuid'
So the latest develop branch of pip DOES install with jython2.7.0 on windows.
Ok, it seems that the jython installer provides a bundled version of pip 1.6. This is quite confusing.
Downloaded the installer .jar from jython.org today and installed it on a fresh Windows 7 machine.
Checked versions in cmd:
Closed first cmd window and opend a new one to check twice:
C:\Users\username>pip -version
Traceback (most recent call last):
File "C:\Jython27\Lib\runpy.py", line 161, in _run_module_as_main
return _run_code(code, main_globals, None,
File "C:\Jython27\Lib\runpy.py", line 72, in _run_code
exec code in run_globals
File "C:\Jython27\bin\pip.exe\__main__.py", line 5, in <module>
File "C:\Jython27\Lib\site-packages\pip\__init__.py", line 10, in <module>
from pip.util import get_installed_distributions, get_prog
File "C:\Jython27\Lib\site-packages\pip\util.py", line 17, in <module>
from pip.locations import (
File "C:\Jython27\Lib\site-packages\pip\locations.py", line 109, in <module>
build_prefix = _get_build_prefix()
File "C:\Jython27\Lib\site-packages\pip\locations.py", line 90, in _get_build_
prefix
if file_uid != os.geteuid():
AttributeError: 'module' object has no attribute 'geteuid'
I was having today the same problem, while installing jython.
Jython installed correctly, but pip installation failed with the same error:
Installing pip and setuptools
90 %
Traceback (most recent call last):
File "C:\jython2.7.0\Lib\runpy.py", line 161, in _run_module_as_main
return _run_code(code, main_globals, None,
File "C:\jython2.7.0\Lib\runpy.py", line 72, in _run_code
exec code in run_globals
File "C:\jython2.7.0\Lib\ensurepip\__main__.py", line 4, in <module>
ensurepip._main()
File "C:\jython2.7.0\Lib\ensurepip\__init__.py", line 220, in _main
bootstrap(
File "C:\jython2.7.0\Lib\ensurepip\__init__.py", line 123, in bootstrap
_run_pip(args + [p[0] for p in _PROJECTS], additional_paths)
File "C:\jython2.7.0\Lib\ensurepip\__init__.py", line 45, in _run_pip
import pip
File "C:\Users\<user>\AppData\Local\Temp\tmpqzn7bu\pip-1.6-py2.py3-none-any.whl\pip\__init__.py", line 10, in <module>
File "C:\Users\<user>\AppData\Local\Temp\tmpqzn7bu\pip-1.6-py2.py3-none-any.whl\pip\util.py", line 17, in <module>
File "C:\Users\<user>\AppData\Local\Temp\tmpqzn7bu\pip-1.6-py2.py3-none-any.whl\pip\locations.py", line 109, in <module>
File "C:\Users\<user>\AppData\Local\Temp\tmpqzn7bu\pip-1.6-py2.py3-none-any.whl\pip\locations.py", line 90, in _get_build_prefix
AttributeError: 'module' object has no attribute 'geteuid'
100 %
Congratulations! You successfully installed Jython 2.7.0 to directory C:\jython2.7.0.
I was able to get rid of that problem by removing the folder %TEMP%\pip_build_<user>
.
Once I could install jython with pip, C:\jython\bin\pip.exe -V
worked fine the first time, but the folder %TEMP%\pip_build_<user>
was created and successive attempts to run the same command failed with the now familiar AttributeError: 'module' object has no attribute 'geteuid'
.
@memoselyk please bold your workaround as it is not visible at first glance
So after nearly a year problem exists and we are forced to use workarounds? :)
It looks like this issue is tracked on Jython bug-tracker: http://bugs.jython.org/issue2521
It is however due to pip lacking Jython-aware Windows detection in pip/compat:
# windows detection, covers cpython and ironpython
WINDOWS = (sys.platform.startswith("win") or
(sys.platform == 'cli' and os.name == 'nt'))
Anyway. I hope we can still fix this on Jython-side by some tricks. Stay tuned for Jython 2.7.1....
@Stewori I noticed that ntpath.py
uses sys.builtin_module_names
and that '_jythonlib' shows up. That might be a clean detector for Jython-awareness ?
UPDATE: I also noticed that ntpath.py
has a note about Jython ?
454 except ImportError: # no built-in nt module - maybe it's Jython ;)
>>> import os
>>> os.path
<module 'ntpath' from 'E:\jython2.7.0\Lib\ntpath$py.class'>
>>> import sys
>>> sys.builtin_module_names
('struct', 'jarray', '_io', '_marshal', 'nt', '_bytecodetools', 'binascii', 'ucnhash', '_sre', 'sys', 'cmath', 'itertools', 'jffi', 'operator', '_py_compile', 'array', 'zipimport', '_codecs', '_hashlib', 'bz2', 'gc', 'cPickle', 'synchronize', '_random', '_imp', 'errno', '__builtin__', '_csv', '_json', '_weakref', 'thread', 'exceptions', '_ast', '_systemrestart', 'cStringIO', '_collections', '_functools', '_threading', '_jythonlib', 'math', 'time')
>>>
@thadguidry indeed, there is some Jython awareness in pip, but not sufficient for this issue. I guess it's because many people work on pip; some care more about Jython, some less. So depending who wrote the code, Jython awareness varies region wise. In pip/compat it would need improvement. However we can fix such stuff now on Jython side (hopefully). os.name/sys.plaform based platform detection has been an ongoing pain with Jython (even more for JyNI). I hope we can get this resolved once for all times by the technique described in http://bugs.jython.org/issue2557.
@Stewori Cool, glad to hear this will be addressed directly in Jython, since our project OpenRefine depends on it and I've added more Jython usage tutorials after uprgrading her to Jython 2.7. Thanks for working through it and we'll be looking forward to that implementation fix in Jython 2.7.1
I'm going to close this as it seems like there's not a specific error here and this is just sort of a generalized Jython + pip issue. If there are specific issues that pip can do to make this work better feel free to open them.
Note that the corresponding issue on Jython bug tracker (http://bugs.jython.org/issue2521) has been fixed for a while. So it should work fine with Jython 2.7.1.
can we install Jython using pip???
@Nimishakk no -- look at jython.org for advice.
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Most helpful comment
I was having today the same problem, while installing jython.
Jython installed correctly, but pip installation failed with the same error:
I was able to get rid of that problem by removing the folder
%TEMP%\pip_build_<user>
.Once I could install jython with pip,
C:\jython\bin\pip.exe -V
worked fine the first time, but the folder%TEMP%\pip_build_<user>
was created and successive attempts to run the same command failed with the now familiarAttributeError: 'module' object has no attribute 'geteuid'
.