We sometimes need to upgrade the packages of the third party installed on the system to the latest version. However, both Easy_install and Pip have no direct command to use.We can use the following command to see which packages on the system are out of date.pip list --outdatedIn fact, we can do this with other shell commands to complete the upgrade.pip freeze --local | grep -v ‘^\-e‘ | cut -d = -f 1 | xargs
How to install pip, the latest tool, by installing python packages in CentOS
To install pip in CentOS 6.4, install the python package management Installation Tool pip in CentOS as follows:
As of the time of writing this article, pip is 1.5.5
Wget -- no-check-certificate https://github.com/pypa/pip/archive/1.5.5.tar.gz
Note: -- no-check-certificate must be add
The concept of "search path" is introduced because when an import statement is used, when the interpreter encounters an import statement, the module is imported if it is in the current search path.A search path is a list of all directories that an interpreter will search first.So how does python add a module search path? One recommended approach is to add a path file, such as Mypkpath.pth, to the Site-packages
Python modules and packages are simply equivalent to namespaces.1,python module A python module is a file with functions, variables, etc.Import ModuleModules-MethodsFrom module Import functionFrom module Import *__name__ = = ' __main__ ' is the decision to run the module yourself or be called to executeIf __name__== '
0. Reply content: If you use Node. js, can you use it if you don't need npm to pull dozens of hundreds of megabytes of data? The python installation package looks like a dozen mb. It was just yesterday that node was used. During the installation, it was only 5 MB in size and thought it was lightweight.
When you started writing code, didn't you always download various packages from npm?
In a project, there
Domestic sourcehttp://pypi.douban.com/Watercresshttp://pypi.hustunique.com/Huazhong University of Technologyhttp://pypi.sdutlinux.org/Shandong University of Technologyhttp://pypi.mirrors.ustc.edu.cn/China University of Science and TechnologyHow to useManually Specify:Manually specify the source, you can follow the PIP and-I to specify the source, such as the source of the watercress to install Slinter (remember to add simple after the source address):$sudoPip3Install-I. http://Pypi.douban.com/si
Module: Write code saved as a file. This file is a module. sample.py where the file name Smaple is the module name.Package: A package is a hierarchical file directory structure that defines a Python application execution environment consisting of n modules or N sub-packages.Popular point: The package is a directory containing __init__.py files, which must have this __init__.py file and other modules or sub-package
Example
Comprehensive utilization of two packages of a similar to Linux under the LS function:
Copy Code code as follows:
#coding = UTF8
Import glob
Import os.path
Path = '/users/zik Ong/pictures '
def ls (path):
#codinf = UTF8
print "--name----type----size----atime----mtime--"
nbsp; Path = path + '/* '
filelist = Glob.glob (path)
for filepath in filelist:
out = '%s%s%s%s% S
Random.sample (sequence, k), randomly fetching fragments of the specified length from the specified sequence. The sample function does not modify the original sequenceNumpy.nonzero () Return The indices of the elements that is non-zero.>>> a = Np.array ([[1,2,3],[4,5,6],[7,8,9]]) >>> a > 3array ([False, False, false], [True, True, true], [True, True, true]], Dtype=bool) >>> Np.nonzero (A > 3) (Array ([1, 1, 1, 2, 2, 2] ), Array ([0, 1, 2, 0, 1, 2])
defaultsPrint (key)Print (config.options (' bitbucket.org ')) # with For loop, find all keys under ' bitbucket.org 'Print (Config.items (' bitbucket.org ')) #找到 all key-value pairs under ' bitbucket.org 'Print (Config.get (' bitbucket.org ', ' compression ')) # Yes Get method takes deep nested valuesWhen we need to call the system's command, the first thing to consider is the OS module. Use Os.system () and Os.popen () to operate. However, these two commands are too simple to perform complex op
First, the use of the module import1 What is a module?The module is a set of functions of a system, in Python, a py file is a module, such as module.py, where module name modules2 using Modules2.1 Import ModuleThree things happen in the first import module1. Create a namespace for a module2, the execution module corresponding file, will produce the name in 1 the name space3, in the current execution file to get a module name, the module name points to
First, the moduleWe've learned a lot of modules before, and today we'll take a look at how they're used.1.importFirst, customize a module my_moudle.py, that is, the file name is My_moudlePrint('From the my_moudle.py') Money=1000defread1 ():Print('My_moudle->read1->money', Money)defread2 ():Print('My_moudle->read2 calling Read1') Read1 ()defChange ():Global Money Money=0My_moudle ModuleImport statements can be used anywhere in the program, and for the same module is import multiple times, in orde
Problems encounteredIf you encounter title problems with Pip Install or easy_install to install Python's various package on your Mac, seeing this essay should solve the problem.Before are directly installed on the VPS using the Python framework and package, did not expect to install the Mac on the time of this trouble, the first thought is to see if anyone on Baidu has the same problem, the result is very disappointed. Although there is no useful answ
, and will not be executed as a module import) __name__ when the current file is run directly, the result is __main__ __name__ is the module name when the file is imported as a modulehow modules are imported 1.import Module Name2.import Module name as Alias3.from Module Import function/class4.from Module Import *Storage of ModulesImport SYSSys.path #获取当前搜索路径的列表sys.path.append (custom path) #将自定义的路径添加到列表中load order of modules steps to import a module operation:1. Detect if the current module
Python can use Easy_install for various package installations or package offload using Easy_install-m package-name, but there is a problem that the installed version cannot be controlled.Using the source code to install a variety of packages can be extracted after unpacking the package in the root directory of the Python setup.py install installation, but uninsta
("./filePackage/test.txt") a.printFilePath(); a.testReadFile();Directory structure:If __init__.py not write anything, then in the main.py can also write:import filePackage.fileif‘__main__‘: a = filePackage.file.MyFile("./filePackage/test.txt") a.printFilePath();However, it is not recommended to do so, and it is recommended to expose the common classes in the module as described above and refer directly to them. Copyright NOTICE: This article for Bo Master original article, without Bo
In the Pycharm ...When two py files are in the same folder. Directly from the file name import * canWhen two files are in a different folder. You need to include the _init_.py file in the file. There is nothing to write about. But this file is required.Then import the folder name. py File Name import * To invoke a different folderA folder B folder _init_.py d.py c.py e.pyC in Import e:From e Import *C in Import D:From the B folder. D Import *Import C in D:From a folder
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.