For example:
When I want to use OpenSSL, in python I use from OpenSSL import SSL
and to install OpenSSL I do apt-get install python-openssl
or pip install pyopenssl
.
EDIT: Thank you very much for everybody that answered it. But what if I don't know how to install 12345.
Let's say there is a library called 12345 that I don't know how to install and I want to use its module ABCDE. Then in a Python script I would write from 12345 import ABCDE
and to install the library I would try apt-get install python-12345
or pip install 12345
. But not always this works. In this case how can I use that module?
Is there a command line to "install" directly the module or any way that I can discover its related library?
For example: If I try import 12345
I get the error:
>>> import 12345 File "<stdin>", line 1 import 12345 ^ SyntaxError: invalid syntax
I think the question become a bit confused. I'm editing it to try to make it better to understand.
You can see this information using the built in help
function.
For example, I have tornado
installed.
> import tornado
> help(tornado)
The start of the output from this command is currently as following;
Help on package tornado:
NAME
tornado - The Tornado web server and tools
If the package has been correctly configured, the name of the package is listed before hyphen in the NAME section. I've bolded it for you.
In this case then, the pip command to install the tornado package is simply
pip install tornado
If you want to use ABCDE from module 12345, then all you need to install is module 12345 (you can't install just 'ABCDE'). So in general, the answer to you question is :
pip install 12345
Many modules come as "batteries included", so you don't necessarily need to install something. For example, if you do:
>>> import random
>>>
You don't get any error, so that module is part of the Python Standard Library and don't need installing.
You can't just get the modules you need, you have to install the library that contains it. Find needed library in PyPI
from library import module
This command will be the way you want. If you get on error, do this.
import library
This command import all of modules in library.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.