Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I use third party 'libraries' in python?

Disclaimer: This is a very basic question, but keep in mind I come from a Microsoft background, and I've programmed mostly in .NET with Visual Studio (this may help you help me with analogies perhaps)


I started programming a little python for the fun of it, so I downloaded eclipse, and installed PyDev.

I reached a point where I needed to parse a date, and I found an alternive to time.strptime that seemed interesting. That alternative was python-dateutil.

I went ahead and downloaded it, but I had problems when I tried to use it.
Apparently the download includes source files, and I had absolutely no idea how to use it in my "project" in eclipse.

So my very basic questions:

  • Do I need to include the source files directly with my files? Perhaps in a subdirectory? How would I use it in my code (how do I import them in my .py file)?
  • Do I need to "build" (make?) them and reference them? How? How do you "compile" something like that in windows?
  • Am I totally missing some important point?

Thank you for your patience.

like image 911
juan Avatar asked Dec 10 '22 13:12

juan


1 Answers

I went ahead and downloaded it, but I had problems when I tried to use it. Apparently the download includes source files, and I had absolutely no idea how to use it in my "project" in eclipse.

you should use pip in your line of command type :

pip install python-dateutil

this command will do all the thing for you it will download and install the library automatically. if you don't have pip refer to the documentation above to see how you should install it

Do I need to include the source files directly with my files? Perhaps in a subdirectory? How would I use it in my code (how do I import them in my .py file)?

if you have used pip like above no need , you should now just import dateutil in your scripts to use it:

import dateutil

Do I need to "build" (make?) them and reference them? How? How do you "compile" something like that in windows?

everything is done with pip (magic isn't it :) )

Am I totally missing some important point?

Yes python is cool, easy and fun , forget about make ,make install ... Everything in python is easy installable.

And for the love of G.. please use pip (it's an order from the BDFL).

alt text

hope this can help:)

like image 116
mouad Avatar answered Dec 28 '22 17:12

mouad