简体   繁体   中英

How to install 3rd party Python libraries for a single script running on AWS EC2?

I have a script that uses the nltk python library . I'm just trying to wrap my head around how one would install this library and potentially other libraries as well on AWS/EC2. This is a standalone script.

I figured it might be done with the aws cli but the documentation on Amazon seems to be lacking a bit.

Can someone help a complete Python newb with some Python and AWS?!?! :) Thanks!

Normally when you fire up an AWS instance you select an "Image".

These are called Amazon Machine Images or AMI for short.

Typically you would select say ( for example ) an "Ubuntu" AMI.

Example: https://cloud-images.ubuntu.com/locator/ec2/

Select the appropriate AMI and then perform some steps similar to:

  1. Configure and Start your Instance
  2. Shell into your Instance
  3. Run: apt-get install python-setuptools
  4. Run: easy_install nltk

You may also find the Python package(s) you're looking for already available in the repositories of the Distribution/Image you've selected.

Here is the way I used:

curl -O https://bootstrap.pypa.io/get-pip.py
sudo python get-pip.py
# Then use pip to install 3rd party libraries
pip install selenium
# works now

I did as this article points: also using Ubuntu

http://docs.aws.amazon.com/cli/latest/userguide/installing.html

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM