• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Tim Cooke
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
Saloon Keepers:
  • Piet Souris
Bartenders:

Questions about Jython/Python

 
Ranch Hand
Posts: 40
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Are Jython & Python 100% interoperable with each other?

Is it possible to import Python libraries into Jython?

I want to use Kotlin as a base & import libraries into Kotlin.
 
Sheriff
Posts: 28536
114
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
From what I read, Jython is an implementation of Python which is written in Java, or at least it runs on the JVM. Also from what I read, there's several bits of sketchiness involved in using Jython which would make me decide to avoid it.

 
Marshal
Posts: 4953
625
VSCode Eclipse IDE Redhat MicroProfile Quarkus Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If it matters for your project, I believe that the most recent version of jython supports python 2.7.
 
Bartender
Posts: 29139
215
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Ron McLeod wrote:If it matters for your project, I believe that the most recent version of jython supports python 2.7.


...Which is a matter of concern, since Python 2 is now completely dead and unsupported. That, presumably includes most of the Python 2 support libraries.

Python 3 is to Python 2 as VB.Net is to Visual Basic. It takes some work to convert. In fact, my favorite recipe manager program would have taken so much work that I simply created an alternative implementation in Java.
 
Bartender
Posts: 299
7
Android Python Oracle Postgres Database Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Even compared to C-Python2 Jython was never compatible and lacked of many libraries.

It is (was?) more are or less the implementation of Python syntax on top of the JVM plus some basic libraries.

Java APIs can be in addition used from Jython and an example for that the usage in older Websphere as language for admin scripts.

 
David Clark
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well, based on what you've said, I eliminate Jython from the competition.

I'd like to learn Python. If I create a Python app & send it to a friend who has a Windows PC, wouldn't he need to have Python installed on his PC?
 
Roland Mueller
Bartender
Posts: 299
7
Android Python Oracle Postgres Database Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

David Clark wrote:

I'd like to learn Python. If I create a Python app & send it to a friend who has a Windows PC, wouldn't he need to have Python installed on his PC?



Jython also requires an additional install in addition to the Java JVM as one can read HERE (https://www.jython.org/download)
 
Ranch Hand
Posts: 155
1
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

David Clark wrote:Well, based on what you've said, I eliminate Jython from the competition.

I'd like to learn Python. If I create a Python app & send it to a friend who has a Windows PC, wouldn't he need to have Python installed on his PC?



Your friend must have installed a Python Interpreter in order to interpret your app.
 
David Clark
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Is there such a thing as a Python package that includes the Python interpreter so that my friend doesn't have to install the Python interpreter? I just send the file to him & he double-clicks on the file & opens the program.
 
Tim Holloway
Bartender
Posts: 29139
215
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Python has gotten to be pretty popular on Microsoft Windows, But it's not pre-installed like on most Linux distros (The Red Hat boot time hardware configurer: Anaconda, was written in Python).

Still,  it's a fairly easy install from the Microsoft Store or python.org.

Note that the popular way to install Python packages is via the "pip" utility.

Also note that depending on how you invoke it, pip installs to either:

A. Global packages (needs administrator rights)
B. User account
C. Virtual Environment ("venv")

If you wish to create your own packages and distribute them, you'd make a "wheel" file, like a Java JAR using the Python wheel utility to bundle up your package in an installable ZIP-format ".whl" file. It will include both your package code and installation metadata, including any dependencies that your package has.
 
David Clark
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Excellent! I was hoping that you would say that!

You state:
Also note that depending on how you invoke it, pip installs to either:

A. Global packages (needs administrator rights)
B. User account
C. Virtual Environment ("venv")

If you wish to create your own packages and distribute them, you'd make a "wheel" file, like a Java JAR using the Python wheel utility to bundle up your package in an installable ZIP-format ".whl" file. It will include both your package code and installation metadata, including any dependencies that your package has.


A. What's a global package? Whose administrator's rights - mine or my friend's?

B. Whose user account - mine or my friend's?

C. Is a virtual Environment ("venv") the same as JVM?

Is the wheel file part of the Python software? If I do as you suggest, the Python interpreter & all other dependencies are included in the package, correct? I guess that my friend double-clicks on the package & it opens, right?
 
Tim Holloway
Bartender
Posts: 29139
215
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
A "global" package is simply one that all users on the system can use. Bear in mind that while Windows is a single-user system, The Unix/Linux family has roots in systems where more that one user can be logged in at the same time. They have a master administrative "root" user account in addition to ordinary user accounts.

Windows differs in that often there will be only one user account on a machine, but Windows has different security attributes which can be assigned as needed. The "run as administrator" feature is a case in point.

So a global package installation is when a package is installed in a directory subtree that's on the python path of every user account on the machine, just like PATH would typically have "C:\{Program Files". It's managed under administrator rights to ensure no user accidentally damages or removed the package and thus screws up other users. I don't know the exact location for Windows, since it's not an absolute location even under Linux, just wherever the Python system has configured it to be.

So much for global.

You log into Windows using a user ID and password. The Window "control panel" functions (whatever they're calling them this week ) allow you to define additional user logins. Each would normally have a home directory under C::\Users. Per-user (local) packages would be installed under a (probably hidden) sub-directory in the user's home directory.

The Virtual Environment is an interesting quirk of Python, it's basically a jail for a custom Python installation with its own executables and libraries. It's handy for testing (so you don't screw up production stuff) and for isolated projects. It contains its own PATH, so you can use an an alternate version of Python and its utilities as defaults within the project.

And no, you cannot ship out a venv and expect it to run on another machine because it's built off your installation setup. You have to have Python already installed to create a venv.

A Wheel is, like I said, a lot like a JAR file for Python. And like executable JARs, it does NOT contain Python. You have to install Python separately, But it can pull package dependencies, which is something JARs cannot do.

It you want to set up a one-button install for a Python app on Windows, then you'll need to use the Windows package management system, bundle up both the Python interpreter and a PIP install of the wheel that defines your actual app. I have not worked that intimately with Windows in about a decade. Back then it would be an MSI setup. but beyond that I cannot say.
 
David Clark
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well, shucks!

Based on what you've said & my understanding of it, I won't be able to send a Python app to my friend who has a Windows PC!
 
Tim Holloway
Bartender
Posts: 29139
215
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

David Clark wrote:Well, shucks!

Based on what you've said & my understanding of it, I won't be able to send a Python app to my friend who has a Windows PC!


Well, like most modern languages, Python doesn't run as native executable (.exe) code, it's run under a language environment. The Python executable for Python, A JVM for Java, A JacaScript interpreter for JavaScript, Likewise for Ruby, and so forth.

And yes, Windows is exceptionally impoverished when it comes to built-in support for such languages.

But it's supposed to be an easy install for a Windows user to install the Python interpreter from the Microsoft Store. Once that is done, it's easy to install and run a Python Wheel file.

If your friend is a helpless/hopeless drooling user, then I suppose that might be too much. More savvy people should have no problem. It doesn't require any special expertise to install stuff from the Microsoft Store.
 
reply
    Bookmark Topic Watch Topic
  • New Topic