一区二区三区日韩精品-日韩经典一区二区三区-五月激情综合丁香婷婷-欧美精品中文字幕专区

分享

How to install and configure Python on a hosted server

 寧?kù)o致遠(yuǎn)oj1kn5 2019-05-21
Uncoiling the path to Python

Developers know that you can’t spell LAMP (Linux, Apache, MySQL, Perl/PHP/Python) on many systems without Python. And although, you are probably well aware that LAMP is the server stack powering today’s Internet, you might be wondering why you should pay attention to Python. Read on for more about the power of Python and how to install and configure this high-level programming language on a hosted server.

What is Python?

Among all three aforementioned programming languages, Python is king. Why? Clear programs, code readability and convenience (read: fewer lines of code). Python takes the bite out of a developer’s job in some ways because, once written, this general-purpose language can run pretty much on any computer without requiring you to change the program. Python is key to such Internet essential programs as the GNU Mailman, mailing-list manager; Yum, the Red Hat Enterprise Linux (RHEL) family’s package manager; and the Zope content-management system (CMS) application server.

How to check whether Python is already installed

Chances are Python is already installed on your hosted Linux server. If you’re unsure, follow these easy steps:

1. Run the following from your ssh terminal:

$ ls -la /usr/bin/python

Note: Keep in mind /usr/bin/python is the default location for the python executables.

2. Use the following command to see which version of Python you’re working with:

$ Python -V

How to check which version of Python you are running

Checking which version of Python you are running depends on which Linux you’re using and the patches that have been applied to it. With many hosted servers running the CentOS 6 distribution of Linux, the server uses Python 2.6.6. But again, it’s best to double check. Plus, if you’d rather use a newer version of Python, say Python 2.7.2, that never version might be already installed.

What you’ll need to install and configure Python

To get going with Python, you’ll need a server. We recommend a GoDaddy VPS or a full dedicated server if you’re ready to take total control. Additionally, various GoDaddy shared hosting plans — including Deluxe, Premium, Unlimited, or Ultimate Linux Web and Classic — support Python. (Note: It is not available on cPanel and Plesk Economy shared hosting accounts.) Now, you might be asking yourself, “What kind of hosting account do I have?” Simply log into your account, locate the Products tab, then expand your view of Servers by clicking the “+” button to the left. You should see which kind of server account you own.

Which version of Python to use

The vast majority of Python-based apps will run just fine with Python 2.6.x or 2.7.x. The latest version is up to Python 3.4.3 (as of May 2015), but updates to the Python 2.7 branch are still not ready. The Python community supports both Python 2.x and 3.x, because Python 2.x was, and remains, very popular. Many programs still rely on it. Furthermore, Python 3.x is not fully backwards-compatible with some Python 2.x features. If you prefer to use Python 3.x, refer to the step-by-step installation instructions below.

How to install Python 3

If you’re brave, you can install Python 3 yourself by taking the following steps:

1. Transfer the compression version of the files to your server.

$ wget https://www./ftp/python/3.4.3/Python-3.4.3.tgz

2. Decompress the files with the following command:

$ tar xvzf Python-3.4.3.tgz

Note: This will create the directory /home/user-name/Python-3.4.3 and automatically decompress all of Python’s files into their appropriate spots.

3. Go into that directory with:

$ cd Python-3.4.3

4. Once inside that directory, install your new version of Python.

$ ./configure --prefix=$HOME/.local

Note: This step sets up your configuration and makes files.

5. Then run this command:

$ make

6. And follow that up with:

$ make install

The last command will install two of the most useful Python utilities:

  • pip: Python’s recommended tool for installing Python packages.
  • setuptools: Enables you to download, build, install, and uninstall Python packages.

Fairly easy, but you’re not done yet. Next, you must add the path to your environment. I use vi, the one true editor, for this but you can use Emacs, nano, or any other pure text editor. Never use a word processor, such as Microsoft Word or LibreOffice Writer. These add formatting codes to their documents, which make them worse than useless for coding purposes.

1. Go into your Bash profile configuration file:

$cd $home
$ vi .bash_profile

2. With an editor, add the following lines, then save the file:

# Python 3 
export PATH="$HOME/.local/bin:$PATH"

3. Run the following to get your environment up to date:

$ source ~/.bash_profile

4. Then run the following from the shell and you should see Python 3.4.3:

$ python3 -V

You now have Python 3 installed. Congratulations!

Why not just run “python”?

If you just run “python,” the executable will show the version number for the default Python for your version of Linux — not your newly installed version of Python. Confusing, I know. You will now have two versions of one language on your server.

The best way to handle this is to use Python’s virtualenv module to create a virtual Python environment. Inside this container-like environment, you can use your newer version of Python — such as Python 3.4.3 or 2.7.2. — without interfering with the preexisting Python.

How to create a virtual Python environment

The easiest way to create a virtual Python environment is to use pip.

1. Install virtualenv for all users on your server with this basic command:

$ python3 -m pip install virtualenv

2. Or, if you’d rather keep this to the current user, use this command:

$ python -m pip install –user virtualenv

3. Then create a directory to use your new environment:

$ mkdir PythonTest

4. Enter the new directory:

$ cd PythonTest

5. And run the following to create a virtual Python environment, named PythonTest, in the PythonTest directory:

$ virtualenv PythonTest

6. Activate this new Python “container” with:

$ source PythonTest/bin/activate

Your shell prompt should now include PythonTest, or whatever you named your Python environment. Now, you’re ready to start programming with Python. Of course, you can always just use a default older Python as well.

For more on the basics of using virtualenv, see Python Guide’s Virtual Environments. Or, if you’re new to Python, refer to the Beginner’s Guide to Python. Got questions or comments on taming the beast we call Python? Connect with the dev community, and share your breakthroughs (or even your breakdowns) in the comments below.

Image by: jurvetson via Compfight cc

    本站是提供個(gè)人知識(shí)管理的網(wǎng)絡(luò)存儲(chǔ)空間,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點(diǎn)。請(qǐng)注意甄別內(nèi)容中的聯(lián)系方式、誘導(dǎo)購(gòu)買等信息,謹(jǐn)防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請(qǐng)點(diǎn)擊一鍵舉報(bào)。
    轉(zhuǎn)藏 分享 獻(xiàn)花(0

    0條評(píng)論

    發(fā)表

    請(qǐng)遵守用戶 評(píng)論公約

    類似文章 更多

    亚洲精品伦理熟女国产一区二区| 日韩亚洲精品国产第二页| 日韩高清毛片免费观看| 免费午夜福利不卡片在线 视频 | 成人午夜免费观看视频| av一区二区三区天堂| 91一区国产中文字幕| 亚洲一区二区三区国产| 欧美一级黄片免费视频| 国产无摭挡又爽又色又刺激| 日本高清不卡在线一区| 深夜福利亚洲高清性感| 人妻少妇系列中文字幕| 午夜精品久久久免费视频| 成人精品一区二区三区在线| 日韩欧美精品一区二区三区| 丝袜破了有美女肉体免费观看| 亚洲精品成人午夜久久| 亚洲免费黄色高清在线观看| 69精品一区二区蜜桃视频| 欧美日韩精品一区二区三区不卡| 小黄片大全欧美一区二区| 久热香蕉精品视频在线播放| 亚洲国产av在线视频| 亚洲一区二区三在线播放 | 日本深夜福利视频在线| 日韩欧美综合在线播放| 国产又粗又猛又长又黄视频| 又色又爽又无遮挡的视频| 日本理论片午夜在线观看| 老司机精品在线你懂的| 亚洲国产成人精品一区刚刚 | 四十女人口红哪个色好看| 国产又猛又大又长又粗| 精品综合欧美一区二区三区| 国内九一激情白浆发布| 欧美日韩亚洲国产av| 亚洲欧美日韩色图七区| 国产亚洲中文日韩欧美综合网| 日本一区二区三区久久娇喘| 中文字幕佐山爱一区二区免费|