SeleniumLibrary icon indicating copy to clipboard operation
SeleniumLibrary copied to clipboard

Error while installing using pip + Jython 2.7.0 on Windows 8.1

Open Tset-Noitamotua opened this issue 11 years ago • 19 comments

In Windows 8.1 cmd / shell jython -m pip install robotframework-selenium2library leads to this error:

Traceback (most recent call last):
  File "C:\Jython27\Lib\runpy.py", line 151, in _run_module_as_main
    mod_name, loader, code, fname = _get_module_details(mod_name)
  File "C:\Jython27\Lib\runpy.py", line 151, in _run_module_as_main
    mod_name, loader, code, fname = _get_module_details(mod_name)
  File "C:\Jython27\Lib\runpy.py", line 109, in _get_module_details
    return _get_module_details(pkg_main_name)
  File "C:\Jython27\Lib\runpy.py", line 109, in _get_module_details
    return _get_module_details(pkg_main_name)
  File "C:\Jython27\Lib\runpy.py", line 101, in _get_module_details
    loader = get_loader(mod_name)
  File "C:\Jython27\Lib\pkgutil.py", line 478, in get_loader
    return find_loader(fullname)
  File "C:\Jython27\Lib\pkgutil.py", line 488, in find_loader
    for importer in iter_importers(fullname):
  File "C:\Jython27\Lib\pkgutil.py", line 439, in iter_importers
    __import__(pkg)
  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'

Tset-Noitamotua avatar May 29 '15 13:05 Tset-Noitamotua

This library doesn't support the Jython version of robotframework. There is a java port of this library, but we have no direct association with it.

just-be-dev avatar May 29 '15 14:05 just-be-dev

Is there a reason not to support Jython 2.7? Has anyone tested does Selenium itself work with it? Old SeleniumLibrary supported Jython and I don't think we had any special code for it. The initial reason Jython support was dropped was that Selenium dropped Python 2.5 support and Jython 2.7 was still in alpha phase. Now that Jython 2.7 is released things are different.

pekkaklarck avatar May 29 '15 16:05 pekkaklarck

I'm not honestly sure. I've done no tests with it myself. I'll open an investigation issue on it.

just-be-dev avatar May 29 '15 17:05 just-be-dev

The error message is occuring when trying to build a nice error message, which blows up when not on nix. PIP is trying to create a folder with marker file in the temp folder an an OSError is being raised. I would try deleting %TEMP%\pip_build_ and trying again. Also check that you have disk space available.

ombre42 avatar Jun 01 '15 17:06 ombre42

@ombre42, was I mistaken? Do we support the Jython version?

just-be-dev avatar Jun 01 '15 17:06 just-be-dev

I can't really answer as to whether we support it, but I think its a good idea. I have not even tried to use Jython 2.7 Final. It just seemed like it could be a machine-specific issue and I was trying to help. As far as I know the only reason Jython was not supported was Selenium started using Python 2.6/7 syntax and/or features and decided not to keep compatability with 2.5 like Pekka said (see https://code.google.com/p/selenium/issues/detail?id=1559). There are several workarounds in RF for bugs in Jython, but maybe S2L will not have that. I'm going to do a smoke test and see...

ombre42 avatar Jun 01 '15 21:06 ombre42

Cool, let me know the results.

just-be-dev avatar Jun 01 '15 21:06 just-be-dev

@ombre42, we have actually been able to remove most if not all Jython workarounds from RF. Jython 2.7 has much better Python compatibility than Jython 2.5 had in general, and also Java integration has got better:

>>> from java.util import HashMap
>>> from collections import Mapping
>>> isinstance(HashMap(), Mapping)
True

This doesn't mean Se2Lib would work on Jython 2.7 out-of-the-box. My guess is that possible problems on the library side would be easy to fix, but possible problem on Selenium might be more complicated.

pekkaklarck avatar Jun 01 '15 23:06 pekkaklarck

I tried to install using pip and reproduced this issue. I followed my own instructions (deleted %TEMP%\pip_build_* and retried) and fortunately that was all it took. Not sure if its a bug in Jython, PIP, or S2L's setup. Afterwords I ran a hello world kind of test and it ran fine. I invoked RF from RIDE using a script jython -m robot.run %*.

So there's hope. Selenium claims Jython 2.7 compatability as of 2.25. @pekkaklarck thanks for the update. It must feel good to remove workarounds.

ombre42 avatar Jun 02 '15 15:06 ombre42

I tested installing Se2Lib on Jython with pip and didn't have any problems. Could it be that if you install Jython itself (and pip with it) as an administrator, it leaves a temp dir that normal user cannot actually use?

@ombre42, it definitely was great to remove old workarounds. =)

pekkaklarck avatar Jun 02 '15 21:06 pekkaklarck

I investigated some more. The error in the OP didn't just occur when installing S2L, it also occured when trying to check pip's version jython -m pip --version or doing import pip in the interpreter. After every single task using pip, I had to delete a temp folder to get it to run. The version reported was 1.6.dev1, which is pretty old. Looking at the traceback in the OP, @Tset-Noitamotua had the same or nearly the same version. After removing jython and the pip cache and starting over, I am ending up with pip 7.0.3, which runs fine. I don't understand how the old version of pip ended up in the Jython install, but the best resolution is to get off the old version.

If anyone should run into this, here's my suggestion:

  1. rename or delete the folder %TEMP%\pip_build_
  2. run jython -m pip install -U pip to upgrade pip

That old version of pip is calling os.mkdir on a folder that exists, raising OSError ([Errno 17] File exists). Probably the folder is always supposed to be deleted before pip exits and that wasn't working.

This code was never hit because pip is calling a *nix only function on Windows:

            print(
                "pip will not work until the temporary folder is either "
                "deleted or is a real directory owned by your user account."
            )

ombre42 avatar Jun 03 '15 13:06 ombre42

My understanding is that Jython, similarly as Python, contains a certain bundled pip version in the installer package, but that version ought to be automatically updated to the latest version as part of the installation.

pekkaklarck avatar Jun 04 '15 07:06 pekkaklarck

I tried @ombre42 ´s suggestion. But it didn´t help in my case. Now no matter what follows after

jython -m pip

e.g. jython -m pip --version or jython -m pip install <package-name> etc.

I get this output:

Traceback (most recent call last):
  File "C:\Jython27\Lib\runpy.py", line 151, in _run_module_as_main
    mod_name, loader, code, fname = _get_module_details(mod_name)
  File "C:\Jython27\Lib\runpy.py", line 151, in _run_module_as_main
    mod_name, loader, code, fname = _get_module_details(mod_name)
  File "C:\Jython27\Lib\runpy.py", line 104, in _get_module_details
    if loader.is_package(mod_name):
AttributeError: 'org.python.core.JavaImporter' object has no attribute 'is_package'

Tset-Noitamotua avatar Jun 05 '15 17:06 Tset-Noitamotua

@ombre42 @pekkaklarck BTW: I opend a question on this matter on stackoverflow.

Tset-Noitamotua avatar Jun 05 '15 17:06 Tset-Noitamotua

@Tset-Noitamotua I had the same problem as you (is_package error). I was not able to resolve it and ended up experimenting on a cleaner machine (no Java, Python, or Jython). Pekka ran into this too, but was able to resolve it.

ombre42 avatar Jun 05 '15 18:06 ombre42

I took a look in installation folder of Jython (C:\Jython27 in my case) after unsetting JYTHON_HOME, restarting my machine and reinstalling Jython. This is the content of the site-packages folder:

image

Seems that outdated dev versions of pip and setuptools are installed by default.

I tried to update with this command:

C:\Jython27\bin>jython -m ensurepip -U

But still ended up with old version of pip:

Ignoring indexes: https://pypi.python.org/simple/
Unpacking c:\users\wladis~1\appdata\local\temp\tmpfwwqqg\setuptools-14.3.2-py2.py3-none-any.whl
Unpacking c:\users\wladis~1\appdata\local\temp\tmpfwwqqg\pip-1.6-py2.py3-none-any.whl
Installing collected packages: setuptools, pip
  Found existing installation: setuptools 14.3.2.dev0
    Uninstalling setuptools:
      Successfully uninstalled setuptools
  Found existing installation: pip 1.6.dev1
    Uninstalling pip:
      Successfully uninstalled pip
Successfully installed setuptools pip
Cleaning up...

C:\Jython27\bin>jython -m ensurepip --version
pip 1.6

Then I cd in bin folder of jython´s installation and called pip.exe directly:

C:\Jython27\bin>pip.exe install -U pip

Which downloaded the new pip version an uninstalled the old one (with an little Exception at the end):

Downloading/unpacking pip from https://pypi.python.org/packages/py2.py3/p/pip/pip-7.0.3-py2.py3-none-any.whl#md5=6950e1d775fea7ea50af690f72589dbd
  Downloading pip-7.0.3-py2.py3-none-any.whl (1.1MB): 1.1MB downloaded
Installing collected packages: pip
  Found existing installation: pip 1.6.dev1
    Uninstalling pip:
      Successfully uninstalled pip
Cleaning up...
←[31mException:
Traceback (most recent call last):
  File "C:\Jython27\Lib\site-packages\pip\basecommand.py", line 133, in main
    "()": IndentingFormatter,
  File "C:\Jython27\Lib\site-packages\pip\commands\install.py", line 325, in run

    options.no_clean = True
  File "C:\Jython27\Lib\site-packages\pip\commands\install.py", line 325, in run

    options.no_clean = True
  File "C:\Jython27\Lib\site-packages\pip\req\req_set.py", line 648, in install
  File "C:\Jython27\Lib\site-packages\pip\req\req_install.py", line 655, in comm
it_uninstall
    # package installed by easy_install
  File "C:\Jython27\Lib\site-packages\pip\req\req_uninstall.py", line 147, in co
mmit
    for pth in self.pth.values():
  File "C:\Jython27\Lib\site-packages\pip\util.py", line 47, in rmtree
  File "C:\Jython27\Lib\shutil.py", line 247, in rmtree
    rmtree(fullname, ignore_errors, onerror)
  File "C:\Jython27\Lib\shutil.py", line 247, in rmtree
    rmtree(fullname, ignore_errors, onerror)
  File "C:\Jython27\Lib\shutil.py", line 252, in rmtree
    onerror(os.remove, fullname, sys.exc_info())
  File "C:\Jython27\Lib\shutil.py", line 250, in rmtree
    os.remove(fullname)
OSError: unlink(): an unknown error occurred: C:\Users\WLADIS~1\AppData\Local\Te
mp\pip-c7hyld-uninstall\jython27\bin\pip.exe

←[0m←[31mStoring debug log for failure in C:\Users\Wladislaw\.pip\pip.log
←[0m

Now I´m getting more of these OSErrors when trying to install packegas through jython -m pip ..

OSError: [Errno 20] Not a directory: 'C:\\Users\\Wladislaw/.cache\\pip\\wheels\\
7b\\4b\\02\\056fcea6f4d49071f0eb0e0a286cf0dbc89cf16e7652d3eb55'
←[0m

I´ll give it up for today and will retry with a completly fresh set up the next days :-(

Tset-Noitamotua avatar Jun 05 '15 20:06 Tset-Noitamotua

Check also do you have a directory named pip (any dir, no need to have ,__init__.py) where you run pip. Jython my end up importing it as a Java package. You can also try import pip on the Jython console and inspect is the pip that you get legit.

Additionally you could try running path/to/jython2.7/bin/pip directly.

Has anyone submitted a bug report about these issues to http://bugs.jython.org?

pekkaklarck avatar Jun 06 '15 06:06 pekkaklarck

I also came across a similar issue when installing sift in jython 2.7, does anybody know how to fix the issue please?

xinlihux avatar Oct 21 '15 09:10 xinlihux

Could you please tell me which Jython package you are using where you are getting all the pip package too. Or could you please share me the folder location. Because whatever version of Jython I am using getting an error while running the command : “jython –m pip install robotframework” Error: Jython.exe: No module named pip.

N.B: I have both Jython 2.7.0 and jython-installer-2.7.1b3.

Muddesir avatar Feb 22 '17 21:02 Muddesir