DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports Events Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
  1. DZone
  2. Software Design and Architecture
  3. Integration
  4. NetBeans IDE + virtualenv = Your Python Experimental Bed

NetBeans IDE + virtualenv = Your Python Experimental Bed

Amit Saha user avatar by
Amit Saha
·
Jan. 24, 09 · Interview
Like (0)
Save
Tweet
Share
8.10K Views

Join the DZone community and get the full member experience.

Join For Free

virtualenv is a tool to build sandbox(ed) or isolated Python environments. Using it you can create multiple isolated Python development environments each with their own isolated 'site-packages', which basically means giving yourself a playground which you might as well need during all the hacking. The page here http://pypi.python.org/pypi/virtualenv has a lot of details on how you can go about installing it and then creating your own sand boxes. Here is what you would do on a Ubuntu box, if you have setuptools installed:

Installation:

$sudo easy_install virtualenv

Searching for virtualenv
Reading http://pypi.python.org/simple/virtualenv/
Best match: virtualenv 1.3.2
Downloading http://pypi.python.org/packages/2.5/v/virtualenv/virtualenv-1.3.2-py2.5.egg#md5=f2cd2b10b8be8b57e74cb1830fc0b504
Processing virtualenv-1.3.2-py2.5.egg
creating /home/amit/virtualenv-local/lib/python2.5/site-packages/virtualenv-1.3.2-py2.5.egg
Extracting virtualenv-1.3.2-py2.5.egg to /home/amit/virtualenv-local/lib/python2.5/site-packages
Adding virtualenv 1.3.2 to easy-install.pth file
Installing virtualenv script to /home/amit/virtualenv-local/bin

Installed /home/amit/virtualenv-local/lib/python2.5/site-packages/virtualenv-1.3.2-py2.5.egg
Processing dependencies for virtualenv
Finished processing dependencies for virtualenv

Creating a isolated Python environment:
$ virtualenv --no-site-packages virtual-env-1
virtualenv --no-site-packages virtual-env-1
New python executable in virtual-env-1/bin/python
Installing setuptools............done.

The above command creates a new Python virtualenv with the name 'virtual-env-1' under your pwd. Couple of things to note:
  • --no-site-packages: This option makes sure that when you are using the Python interpreter, it will *not* look into the global site-packages for third party packages (See this discussion for more on this topic)
  • setuptools is installed automatically, so that you can start doing a easy_install (and more) in your Python environment just created
Okay, so your sandbox is ready. Let us see, what is in there:
.
|-- bin
| |-- activate
| |-- activate_this.py
| |-- easy_install
| |-- easy_install-2.5
| `-- python
|-- include
| `-- python2.5 -> /usr/include/python2.5
`-- lib
`-- python2.5
|-- UserDict.py -> /usr/lib/python2.5/UserDict.py
|-- UserDict.pyc -> /usr/lib/python2.5/UserDict.pyc
|-- codecs.py -> /usr/lib/python2.5/codecs.py
|-- codecs.pyc -> /usr/lib/python2.5/codecs.pyc
|-- config -> /usr/lib/python2.5/config
|-- copy_reg.py -> /usr/lib/python2.5/copy_reg.py
|-- copy_reg.pyc -> /usr/lib/python2.5/copy_reg.pyc
|-- distutils
| |-- __init__.py
| |-- __init__.pyc
| `-- distutils.cfg
|-- encodings -> /usr/lib/python2.5/encodings
|-- fnmatch.py -> /usr/lib/python2.5/fnmatch.py
|-- fnmatch.pyc -> /usr/lib/python2.5/fnmatch.pyc
|-- lib-dynload -> /usr/lib/python2.5/lib-dynload
|-- locale.py -> /usr/lib/python2.5/locale.py
|-- locale.pyc -> /usr/lib/python2.5/locale.pyc
|-- no-global-site-packages.txt
|-- ntpath.py -> /usr/lib/python2.5/ntpath.py
|-- ntpath.pyc -> /usr/lib/python2.5/ntpath.pyc
|-- orig-prefix.txt
|-- os.py -> /usr/lib/python2.5/os.py
|-- os.pyc -> /usr/lib/python2.5/os.pyc
|-- posixpath.py -> /usr/lib/python2.5/posixpath.py
|-- posixpath.pyc -> /usr/lib/python2.5/posixpath.pyc
|-- re.py -> /usr/lib/python2.5/re.py
|-- re.pyc -> /usr/lib/python2.5/re.pyc
|-- site-packages
| |-- easy-install.pth
| |-- setuptools-0.6c9-py2.5.egg
| `-- setuptools.pth
|-- site.py
|-- site.pyc
|-- sre.py -> /usr/lib/python2.5/sre.py
|-- sre.pyc -> /usr/lib/python2.5/sre.pyc
|-- sre_compile.py -> /usr/lib/python2.5/sre_compile.py
|-- sre_compile.pyc -> /usr/lib/python2.5/sre_compile.pyc
|-- sre_constants.py -> /usr/lib/python2.5/sre_constants.py
|-- sre_constants.pyc -> /usr/lib/python2.5/sre_constants.pyc
|-- sre_parse.py -> /usr/lib/python2.5/sre_parse.py
|-- sre_parse.pyc -> /usr/lib/python2.5/sre_parse.pyc
|-- stat.py -> /usr/lib/python2.5/stat.py
|-- stat.pyc -> /usr/lib/python2.5/stat.pyc
|-- types.py -> /usr/lib/python2.5/types.py
`-- types.pyc -> /usr/lib/python2.5/types.pyc

10 directories, 45 files
The directory tree is pretty straight forward and spend some time looking at it. Now you can do two things:
  • Make this the default Python interpreter, using 'activate_this.py'
  • or, simply refer to it using the full pathname, such as : ~/virtual-env-1/bin/python

Using 'virtualenv' on NetBeans IDE for Python:

Coming to the main focus of this post, you can use your newly created virtualenv with the NetBeans IDE for Python. Just add a new platform using Tools > Python Platforms > New: 

                               

Once added, you can verify the Python Path: 

Now, you can either make it the default platform or make your use of this platform for your selected experimental projects!

Your Python test bed is ready!

Integrated development environment Python (language) NetBeans

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • How To Convert HTML to PNG in Java
  • AIOps Being Powered by Robotic Data Automation
  • Image Classification With DCNNs
  • Upgrade Guide To Spring Data Elasticsearch 5.0

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends: