• Shopping Cart Shopping Cart
    0Shopping Cart
London App Developer
  • Courses
  • Consulting
  • Tutorials
  • About
  • Click to open the search input field Click to open the search input field Search
  • Menu Menu
Eclipse Windows and Python software logos on a pink background image
Eclipse, Python, Windows 10

Virtualenv with Eclipse with PyDev on Windows 10

This article will explain how to install virtualenv and create a new Python Project in eclipse which uses a custom virtual environment. There is also a little Hello World style example at the end!

This article assumes that you have Python, Eclipse and the PyDev plugin installed on your machine. If you need to know how to do this, please see my previous post: Setting up your Windows 10 System for Python Development (PyDev, Eclipse, Python).

In the current public version of Python, there is a bug in one of the packages which will display the following error message if you try to install any packages using pip:

Fatal error in launcher: Job information querying failed

This bug has been fixed in the current dev release but still exists in the production version at the time of writing this article. If you want to learn more about the status of this, you can track it via this ticket: http://bugs.python.org/issue24127.

OK let’s get started.

Let me just re-iterate, this article assumes that you have Python installed with the necessary path variables set. If you have not done this or are in doubt, please follow this first: Setting up your Windows 10 System for Python Development (PyDev, Eclipse, Python).

Add Python scripts directory to system path

First, we add the python scripts directory to the system path. We do this so we can feel like we are using a unix based system where you can just type commands line pip into the console and they work (without having to type the full executable URL). Right click the Windows menu and select System.

Windows 10 system menu option screenshot

From the System menu, select Advanced system settings.

Windows 10 system menu screenshot

From the System Properties menu, select the Advanced tab and click on Environment Variables…

Windows 10 system properties screenshot

From the System variables section, location the Path variable, select it and click Edit…

System 10 system properties advanced screenshot

From the Edit System Variable menu, navigate to the end of the Variable value and append:

;C:\Python27\Scripts

(note the semi colon which is used to separate the items in this list. Once done, click OK.

Windows 10 'path' system variable screenshot

Click OK on the Environment Variables screen.

Windows 10 system properties screenshot

On the System Properties screen, click OK.

windows 10 system properties advanced screenshot

Now exit the System menu by clicking X.

Windows 10 system menu screenshot

Install Virtualenv Using Pip and Create Your First Environment

Right click the Windows button and select Command Prompt (Admin). We load it in Admin mode because we are installing packages which will likely require elevated rights.

Windows 10 command prompt (admin) option screenshot

In the Administrator: Command Prompt type the following command to install virtualenv.

python -m pip install virtualenv

The reason we use the “-m” switch is because as mentioned at the beginning of this post, there is a bug in Python for Windows 10 which causes an error to occur when trying to install with pip.

After it’s installed, type exit to quit Command Prompt.

Windows 10 command prompt pip install screenshot

Next, load command prompt again but this time under your user account, by right clicking the Windows buttons and choosing Command Prompt.

Windows 10 Command Prompt Option Screenshot

Command prompt should start in “C:\Users\<username>\”. Create a new directory called virtualenvs by typing in the following command:

mkdir virtualenvs
Widnows 10 Command Prompt Virtualenv Screenshot

Then switch to that new directory by typing:

cd virtualenvs
Windows 10 Command Prompt Change Directory Screenshot

Now we will create a new virtual environment called london_app_dev. A “virtual environment” is a place where all the required Python packages and settings can be stored for a specific project. This allows you to have a unique set of installed packages for each project as opposed to having one shared set. This is useful if some projects require different versions of the same package for example. Create the virtual environment by typing the following command:

python -m virtualenv london_app_dev

Feel free to specify your own name by replacing london_app_dev with whatever you want. Just remember to what you named it, for the rest of the tutorial.

Windows 10 Create Virtual Env Screenshot

Create Your First Python Project in Eclipse

OK, now we have the virtual environment created, run Eclipse.

Windows 10 launch Eclipse Screenshot

Eclipse will load.

Windows 10 Eclipse Splash Screenshot

Once Eclipse loads, select File > New > PyDev Project from the menu.

Windows 10 Eclipse New PyDev Project Screenshot

Enter a Project name. I use the word Kaizen for this demonstration. Click the Please configure an interpreter before proceeding link to configure an interpreter (the thing that understands Python code)

Windows 10 Python PyDev New Project Screenshot

In the Configure interpreter menu, choose Manual Config.

Windows 10 PyDev New Project Python Interpreter Screenshot

In the Preferences screen, select New… next to the Python Interpreters section.

Windows 10 PyDev interpreters screenshot

In the Select interpreter screen, enter the Interpreter Name for your project (in this case, LondonAppDeveloper). In some cases you would give it a generic name such as Python, however because we are giving the project it’s own virtual environment we will give it a name specific to the project. After typing a name, click Browse.

Windows 10 PyDev create interpreter screenshot

In the Open screen, navigate to C:\Users\<user>\virtualenvs\london_app_dev\Scripts (where <user> is your username), and choose python from the list. Then click Open.

Windows 10 Eclipse PyDev select interpreter location screenshot

In the Select interpreter screen, select OK to save the settings and close it.

Windows 10 Eclipse PyDev Interpreter Screenshot

You will then be prompted which files you would like to add to the pythonpath. Leave all selected and choose OK.

Windows 10 Eclipse PyDev select paths to be added to Python Path Screenshot

Marvel at the Python Interpreter you have just added and select OK.

Windows 10 Eclipse Python Interpreters Screenshot

If a firewall request screen pops up for Eclipse, select Allow access.

Windows 10 Eclipse Firewall Request Screenshot

Eclipse will process your selection of Python interpreter.Wait patiently.

Windows 10 Eclipse Progress Information Screenshot

Now, back to the PyDev Project window, from the Interpreter drop down list, select LondonAppDeveloper.

Windows 10 Python Eclipse New Project Interpreter Selection Screenshot

Now you have chosen an Interpreter, click on Finish.

Eclipse Windows 10 New PyDev Project Screenshot

Now we will create our first Python file, on the project you just created (Kaizen), right click and select New > File.

Windows 10 PyDev new file screenshot

In the New File screen, type the name hello_kaizen.py and click Finish.

Windows 10 Eclipse PyDev new file screenshot

On the Default Eclipse preferences for PyDev screen, leave the default selection and click OK.

Windows 10 eclipse PyDev default screenshot

Your new file should automatically open. Enter the following code:

import datetime

def hello_kaizen():
    print("Hello Kaizen:" + str(datetime.datetime.now())) 

hello_kaizen()

This will print the words Hello Kaizen and the current date and time when ran.

Windows 10 Python Hello World Screenshot

After you have written your script, select Run As… from the top menu.

Windows 10 Python PyDev Eclipse Hello World Screenshot

From the Run As menu, choose Python Run and click OK.

Windows 10 Eclipse PyDev run python screenshot

The console screen will appear at the bottom Eclipse, if you see something like the below response, you are done!

Windows 10 Python Eclipse Final Hello World Screenshot

Thank you for reading, I hope this walk-through added some value to your life 🙂

Share this entry
  • Share on Facebook
  • Share on X
  • Share on WhatsApp
  • Share on Pinterest
  • Share on LinkedIn
  • Share on Tumblr
  • Share on Vk
  • Share on Reddit
  • Share by Mail
https://i0.wp.com/londonappdeveloper.com/wp-content/uploads/2015/05/Virtualenv-with-Eclipse-with-PyDev-on-Windows-10.png?fit=277%2C223&ssl=1 223 277 mark https://londonappdeveloper.com/wp-content/uploads/2018/12/lon_website_logo-300x110.png mark2015-05-26 21:17:542022-01-12 10:46:24Virtualenv with Eclipse with PyDev on Windows 10
1 reply
  1. Steve
    Steve says:
    December 6, 2015 at 9:48 pm

    One very important aspect of virtual environments you left out — and the main reason I want to use virtualenvs in the first place — how to install/add packages to the virtual environment

Comments are closed.

Pages

  • About
  • Consulting
  • Home
  • Tutorials

Categories

  • AI
  • Android
  • Android Studio
  • Angular
  • Aptana Studio
  • AWS
  • Bootstrap
  • Career advice
  • Celery
  • Databases
  • Deployment
  • DevOps
  • Django
  • Django REST Framework
  • Docker
  • Eclipse
  • Getting Help
  • Git
  • Git Bash
  • Git Flow
  • GitHub Actions
  • Google App Engine
  • IDE
  • Ionic Framework
  • iOS
  • JavaScript
  • Job Search
  • Links
  • Linux
  • Mac OS X
  • macOS
  • Node.JS
  • OpenAI
  • PGAdmin
  • Postgres
  • Productivity
  • Python
  • React
  • Salt Stack
  • Stack Overflow
  • Tools
  • Travis-CI
  • Tutorials
  • Ubuntu
  • Uncategorized
  • Vagrant
  • VSCode
  • WebSockets
  • Windows 10
  • WordPress

London App Developer Ltd,

71-75 Shelton Street, Covent Garden, London, United Kingdom, WC2H 9JQ

Company registration number: 09718346

© London App Developer - London App Developer Ltd, Company Registration Number: 09718346, VAT: GB224061842
  • Link to X
  • Link to Youtube
  • Link to Facebook
  • Link to Reddit
Link to: Setting up your Windows 10 System for Python Development (PyDev, Eclipse, Python) Link to: Setting up your Windows 10 System for Python Development (PyDev, Eclipse, Python) Setting up your Windows 10 System for Python Development (PyDev, Eclipse, P...Windows and Python software logos over top of a computer screen with code Link to: OnePlus One ADB Access over Network on Windows 10 Link to: OnePlus One ADB Access over Network on Windows 10 OnePlus and Windows logo on a teal backgroundOnePlus One ADB Access over Network on Windows 10
Scroll to top Scroll to top Scroll to top

This site uses cookies. By continuing to browse the site, you are agreeing to our use of cookies.

OKLearn more

Cookie and Privacy Settings



How we use cookies

We may request cookies to be set on your device. We use cookies to let us know when you visit our websites, how you interact with us, to enrich your user experience, and to customize your relationship with our website.

Click on the different category headings to find out more. You can also change some of your preferences. Note that blocking some types of cookies may impact your experience on our websites and the services we are able to offer.

Essential Website Cookies

These cookies are strictly necessary to provide you with services available through our website and to use some of its features.

Because these cookies are strictly necessary to deliver the website, refusing them will have impact how our site functions. You always can block or delete cookies by changing your browser settings and force blocking all cookies on this website. But this will always prompt you to accept/refuse cookies when revisiting our site.

We fully respect if you want to refuse cookies but to avoid asking you again and again kindly allow us to store a cookie for that. You are free to opt out any time or opt in for other cookies to get a better experience. If you refuse cookies we will remove all set cookies in our domain.

We provide you with a list of stored cookies on your computer in our domain so you can check what we stored. Due to security reasons we are not able to show or modify cookies from other domains. You can check these in your browser security settings.

Google Analytics Cookies

These cookies collect information that is used either in aggregate form to help us understand how our website is being used or how effective our marketing campaigns are, or to help us customize our website and application for you in order to enhance your experience.

If you do not want that we track your visit to our site you can disable tracking in your browser here:

Other external services

We also use different external services like Google Webfonts, Google Maps, and external Video providers. Since these providers may collect personal data like your IP address we allow you to block them here. Please be aware that this might heavily reduce the functionality and appearance of our site. Changes will take effect once you reload the page.

Google Webfont Settings:

Google Map Settings:

Google reCaptcha Settings:

Vimeo and Youtube video embeds:

Other cookies

The following cookies are also needed - You can choose if you want to allow them:

Privacy Policy

You can read about our cookies and privacy settings in detail on our Privacy Policy Page.

Privacy Policy
Accept settingsHide notification only