

- #EDIT PYTHON ON LINUX SERVER HOW TO#
- #EDIT PYTHON ON LINUX SERVER INSTALL#
- #EDIT PYTHON ON LINUX SERVER CODE#
With your environment installed, the procedure is pretty much the same in both versions of Python. This makes a bin of python files inside the current directory called my_project. Once you have it, just cd into your project directory and run this command: python program-name.py In Python 3, the virtual environment module may need to be installed. That’s it, jump down to “Using your virtual environment” to see what to do next. With virtualenv installed, you can just cd to your project directory, and then make a new environment: virtualenv (hint for OS X users that got here, try sudo easy_install pip, you might have to use the command as pip2 instead of pip, just check for the –version) Pip’s the most reliable way to manage packages, and like the link above says, it’s the recommended way to do it also.
#EDIT PYTHON ON LINUX SERVER INSTALL#
If you get an error here, saying that you need to install pip first, go ahead and do so. In Python 2 you’ll want to install virtualenv using pip: pip install virtualenv The first thing to do is set up a virtual environment.

It’s a good idea to keep track of these in a text file that can be used by pip to install them later. Any of the packages you get from the package index, for example, will need to be installed on your production machine as well.

You have to remember that for any version of Python, you are going to need to deploy that same setup to your production environment. Setting up a proper environment for working is going to be important, and can be confusing at first, because you might think you are ready to write with it simply installed on your machine. One of the great things about Python is that it is fantastically simple to get working this simplicity is also one of the pitfalls. If you are missing one or the other, or if you find you are running an older version, just install the newest: sudo apt-get install python *or* python# Environments matter Just remember which one your machine defaults to, and which one you are wanting to target. There’s a whole different article to be written about changing your default Python install, so I’m going to avoid that discussion here.
#EDIT PYTHON ON LINUX SERVER CODE#
This will be important because it will determine how we run our Python code from whatever interpreter we end up using. In my case, the default Python install is 2, so I type: python3 -versionĪnd get back the appropriate Python 3.x.x response.

Will return either Python3.x.x or Python 2.x.x.ĭepending on what you get back, I’d also suggest trying the other release as well, by appending that number to the python command. So open a terminal and check what you have: python -version The real issue is finding out which Python version you have installed by default, and which Python version you are planning on programming with. In fact, it’s probably a large part of how your package installer works. Great news, Python’s already thereĪs a *nix user (because this applies to OsX as well) you already have some version of Python installed on your system.
#EDIT PYTHON ON LINUX SERVER HOW TO#
Recently, Python released a new version of their installers that have made that process nearly painless, but that doesn’t mean you get the best development environment out of the box, so, in the spirit of a recent post on It’s FOSS about setting up a C++ environment, here’s how to do the same for Python. If you’ve ever tried to set up a Python development environment in Windows, you know how challenging it can be. Brief: This guide shows you how to set up Python environment on Linux and other Unix-like systems.
