Showing posts with label python 2. Show all posts
Showing posts with label python 2. Show all posts

Monday, July 4, 2022

How to install Python PyDev plugin in Eclipse (Manual installation, not from eclipse marketplace/url)

 Eclipse is a favourite tool for Java/JEE developers (including me ðŸ™‚ ). When I started learning Python, I wanted to use Eclipse as my preferred IDE for Python development. I found out that PyDev is one good open source plugin which can very well integrate with Eclipse.

Although PyDev is available through Eclipse Marketplace, I had some problems making it work from there. After a few hit and trials, I found a way to integrate the plugin in Eclipse without going through the marketplace. With this blog, I would like to share the steps for how to install Python PyDev plugin in Eclipse.

Prerequisites

1. Make sure that the latest version of the Java Development Kit is installed on your computer.
2. Download and install the Eclipse IDE for Java EE Developers for your operating system.

Installation Steps

Download the zip release of PyDev plugin.

Unzip the downloaded PyDev plugin. It will contain two folders; features and plugins

Browse to your Eclipse installation folder and locate the dropins folder

Copy the features and plugins from the unzipped PyDev plugin to the dropins folder

Restart Eclipse and open the PyDev perspective to verify that Pydev plugin has successfully installed

Now that the PyDev plugin is installed, let’s create a Python Hello World project to validate that our IDE is ready to crunch Python code. Open the project wizard and create a new Python project.

If Python is not installed on the system or Python interpreter is not configured, the project creation wizard will show an error “Project interpreter not specified”

If Python is not installed, this is just the right time to do so. Go to the Python website and download the appropriate installer.

After installing Python, go back to the project creation wizard and click on the link text “Please configure an interpreter before proceeding” and in the pop-up window, click on the button, Quick Auto-Config. This will automatically find the installation path of Python and configure Python interpreter in Eclipse.
While you are there, also click on the option, “Create ‘src’ folder and add it to the PYTHONPATH”

Create a package within the HelloWorld src folder and create a module which prints Hello PyDev! text.

Run the program and it should display Hello PyDev! on the console output

Hope that helps. In the next blog, I’ll show you how to install Python packages in Eclipse. See you in the next blog!

Wednesday, June 1, 2022

Ways to convert Python 2 code to Python 3

 There. They are few packages developed over time, one of them is official and extremely powerful.

Three Library that is used to convert your Python 2 code to Python 3 code.

  1. 2to3 (Offical, recommended)
  2. Python Future + Futurize
  3. Six + Modernize

Now at this point, you definitely thinking well, what’s the difference between, 2to3, Python Future + Futurize, and Six + Modernize.

Here’s your answer!


What’s the difference between


Automated tools for PY2 to PY3 conversion/compatibility?

2to3, Python Future + Futurize, and Six + Modernize


How to convert Python 2 to Python 3


This can be very easy if you use any of the above libraries (do not forget to make sure the compatibility)
There are two approaches for converting Python 2 to python 3.


Method #1: Convert Python 2 to python 3 using web-tool.


There is a simple tool for converting python 2 to python 3.

you can use a web application to convert python 2 to 3.

This tool is:

  1. 100% FREE
  2. Compatible with All versions of Python
  3. Actively maintained


Method #2: Convert Python 2 to python 3 using a python library.


We can convert Python2 scripts to Python3 scripts by using the 2to3 module. It changes Python2 syntax to Python3 syntax. We can change all the files in a particular folder from python2 to python3.

Step 1: Open your terminal and navigate to your File


Open your terminal or CMD depend on whatever you are using Windows or Linux.

Navigate to the directory where your python file(s) is/are located. (of course, using the “cd” command)


Step 2: Install the library

As usable, use pip to install 2to3, use can use any other library as well, I like 2to3

Command: pip install 2to3

Step 3: Convert the files

Excute: 2to3 [file or folder] -w