مدیریت وابستگی‌ها در پایتون

1 دقیقه مطالعه

مدیریت کتابخانه‌ها در پایتون

یه مشکلی که من در مورد خیلی‌ها که با پایتون کد میزنن بهش برخوردم این بوده که آدما وقتی می‌خوان یه برنامه‌ی پایتون رو که نوشتن به گیت انتقال بدن و یا یه داکر ایمج ازش بسازن، آدما یادشون میره فایل requirments.txt رو همراه برنامه قرار نمی‌دن تا زندگی خودشون رو راحت‌تر کنن. برای همین تصمیم گرفتم در قالب یه پست یه روش ایجاد این فایل رو روی Ubuntu و Debian توضیح بدم.

نصب

  • اول virtual enviroment پایتون رو با دستور زیر نصب می‌کنیم:
sudo pip3 install -U virtualenv
  • بعد از نصب virtualenv، با دستور زیر یه پوشه می‌سازیم که توش یه مفسر پایتون خشک و خالی نصب شده!
virtualenv  home/$USER/MyPython

بعد اینکار برای ترمینالی که توش هستیم با دستور زیر این مفسر رو فعال می‌کنیم. در واقع تا وقتی این تب از ترمینال رو نبستیم مفسر پایتون نصب‌‌شده توی MyPython استفاده می‌شه.

source  /home/$USER/MyPython/bin/activate 

بعد از اینکه مفسر پایتون مورد نظر رو فعال کردیم به پوشه‌ای که کد‌های خفن پایتونمون توشه می‌ریم و برنامه‌ رو اجرا می‌کنیم.

برای مثال فرض کنین که برنامه‌ی خفن ما یه ماژول هستن که توش کد زیر اجرا میشه:

import numpy as np
import pylab as plt

if __name__ == "__main__":
    mu = 10
    sigma = 3
    xs = sigma * np.random.randn(1000) + mu

    plt.hist(xs, bins=50)
    plt.show()

طی اجرای برنامه‌ها با مفسر تازه نصب‌شده‌ی پایتون برای هر کتابخونه یه پیام خطا می‌گیریم که با استفاده از اون پیام خطا می‌تونیم کتابخونه‌های مورد نظر رو با استفاده از pip برای همین مفسر نصب کنیم.

بعد از نصب همه‌ی کتابخونه‌ها، دیگه برنامه‌ی ما به خوبی اجرا می‌شه. بعد از نصب کتابخونه‌ها ما اسم و ورژن کتابخونه‌های این برنامه رو توی یه فایل تکست که معمولا اسمش هست requirements.txt رو با دستور زیر ذخیره می‌کنیم.

pip freeze >> requirements.txt 

بعد از اینکار مفسر نصبشده رو غیر فعالش می‌کنیم.

deactivate 

استفاده از فایل وابستگی‌ها

هر کس اگه خواست از برنامه‌ی ما استفاده کنه به راحتی می‌تونه وابستگی‌های برنامه رو با داشتن فایل requirements.txt با

sudo pip3 install -r requirements.txt

نصب کنه!

نظر ها

Everything is very open with a very clear explanation of the issues. It was definitely informative. Your website is very useful. Many thanks for sharing!

I’ve been browsing online more than three hours lately, yet I never found any fascinating article like yours. It is beautiful value enough for me. In my view, if all webmasters and bloggers made good content material as you did, the net might be a lot more useful than ever before.

I blog frequently and I truly thank you for your content. This great article has really peaked my interest. I’m going to bookmark your website and keep checking for new details about once a week. I opted in for your Feed as well.

Magnificent beat ! I wish to apprentice while you amend your web site, how can i subscribe for a blog web site?

The account helped me a acceptable deal. I were tiny bit acquainted of this your broadcast offered brilliant transparent concept

I want to to thank you for this very good read!! I absolutely enjoyed every little bit of it. I have you saved as a favorite to look at new things you post…

Aw, this was an incredibly good post. Taking a few minutes and actual effort to generate a superb article… but what can I say… I hesitate a whole lot and don’t manage to get anything done.

Thank you for the auspicious writeup. It in fact was a amusement account it. Look advanced to more added agreeable from you! By the way, how can we communicate?

Its like you read my mind! You seem to know a lot about this, like you wrote the book in it or something. I think that you can do with some pics to drive the message home a little bit, but instead of that, this is great blog.

An excellent read. I will certainly be back.

I am curious to find out what blog platform you have been utilizing? I’m having some minor security problems with my latest site and I would like to find something more safe. Do you have any recommendations?

Hey this is kinda of off topic but I was wondering if blogs use WYSIWYG editors or if you have to manually code with HTML. I’m starting a blog soon but have no coding knowledge so I wanted to get guidance from someone with experience. Any help would be enormously appreciated!

I’m impressed, I have to admit. Rarely do I come across a blog that’s both educative and interesting, and let me tell you, you’ve hit the nail on the head. The problem is an issue that not enough folks are speaking intelligently about. Now i’m very happy that I stumbled across this in my search for something relating to this.

Greate pieces. Keep writing such kind of info on your site. Im really impressed by your site. Hi there, You’ve performed an incredible job. I’ll definitely digg it and in my opinion suggest to my friends. I’m sure they’ll be benefited from this site.

Sweet blog! I found it while surfing around on Yahoo News. Do you have any tips on how to get listed in Yahoo News? I’ve been trying for a while but I never seem to get there! Thanks

With havin so much content and articles do you ever run into any issues of plagorism or copyright infringement? My website has a lot of unique content I’ve either authored myself or outsourced but it looks like a lot of it is popping it up all over the internet without my agreement. Do you know any solutions to help reduce content from being stolen? I’d certainly appreciate it.

Thank you for every other informative blog. The place else may just I am getting that type of information written in such a perfect manner? I have a mission that I am just now working on, and I’ve been at the look out for such info.

Thank you for the good writeup. It in fact was a amusement account it. Look advanced to more added agreeable from you! By the way, how can we communicate?

Pretty nice post. I just stumbled upon your blog and wished to say that I have truly enjoyed browsing your blog posts. After all I will be subscribing to your rss feed and I hope you write again soon!

When I originally commented I clicked the “Notify me when new comments are added” checkbox and now each time a comment is added I get four e-mails with the same comment. Is there any way you can remove people from that service? Thanks a lot!

What i don’t understood is in reality how you are no longer actually much more well-appreciated than you might be right now. You are so intelligent. You realize thus considerably with regards to this topic, made me personally consider it from a lot of various angles. Its like women and men don’t seem to be interested except it’s something to do with Girl gaga!

Your personal stuffs excellent. All the time take care of it up!

I’ve been browsing online more than 2 hours today, yet I never found any interesting article like yours. It is pretty worth enough for me. In my view, if all web owners and bloggers made good content as you did, the internet will be a lot more useful than ever before.

Appreciating the time and energy you put into your site and detailed information you provide. It’s nice to come across a blog every once in a while that isn’t the same outdated rehashed information. Fantastic read! I’ve bookmarked your site and I’m adding your RSS feeds to my Google account.

Hey are using Wordpress for your blog platform? I’m new to the blog world but I’m trying to get started and set up my own. Do you require any html coding knowledge to make your own blog? Any help would be really appreciated!

Ahaa, its fastidious discussion concerning this paragraph at this place at this website, I have read all that, so now me also commenting at this place.

Wonderful goods from you, man. I’ve understand your stuff previous to and you’re just too wonderful. I really like what you have acquired here, really like what you’re stating and the way in which you say it.

You make it enjoyable and you still care for to keep it wise. I cant wait to read far more from you. This is actually a wonderful web site.

Do you mind if I quote a couple of your articles as long as I provide credit and sources back to your site? My website is in the very same niche as yours and my users would definitely benefit from a lot of the information you present here. Please let me know if this ok with you. Appreciate it!

I know this if off topic but I’m looking into starting my own blog and was wondering what all is needed to get set up? I’m assuming having a blog like yours would cost a pretty penny? I’m not very web smart so I’m not 100% sure. Any tips or advice would be greatly appreciated. Thank you

Sweet blog! I found it while surfing around on Yahoo News. Do you have any suggestions on how to get listed in Yahoo News? I’ve been trying for a while but I never seem to get there! Thanks

An impressive share! I’ve just forwarded this onto a coworker who had been conducting a little homework on this. And he in fact bought me dinner because I stumbled upon it for him… lol. So allow me to reword this…. Thanks for the meal!! But yeah, thanks for spending the time to talk about this issue here on your website.

Wow that was odd. I just wrote an really long comment but after I clicked submit my comment didn’t show up. Grrrr… well I’m not writing all that over again. Anyway, just wanted to say fantastic blog!

It’s remarkable to pay a visit this web page and reading the views of all friends concerning this piece of writing, while I am also keen of getting familiarity.

Great article! This is the kind of info that are meant to be shared around the web. Disgrace on the search engines for not positioning this put up higher! Come on over and talk over with my site .

Thank you =)

If some one needs expert view regarding blogging and site-building then i advise him/her to visit this website, Keep up the fastidious job.

I savour, result in I discovered exactly what I was taking a look for. You have ended my 4 day long hunt! God Bless you man. Have a nice day. Bye

You actually make it appear really easy together with your presentation but I to find this topic to be actually one thing that I believe I would never understand. It sort of feels too complex and extremely huge for me. I am having a look ahead to your subsequent post, I will attempt to get the dangle of it!

Magnificent items from you, man. I have take note your stuff prior to and you are just extremely great. I actually like what you’ve obtained right here, certainly like what you’re stating and the way during which you say it. You are making it enjoyable and you still care for to keep it sensible.

I can’t wait to read far more from you. That is really a wonderful site.

naturally like your web-site however you need to check the spelling on several of your posts. Many of them are rife with spelling issues and I in finding it very troublesome to inform the reality then again I will definitely come back again.

My partner and I stumbled over here by a different web page and thought I should check things out. I like what I see so i am just following you. Look forward to checking out your web page for a second time.

Thanks for your personal marvelous posting! I quite enjoyed reading it, you’re a great author.I will make sure to bookmark your blog and will often come back in the foreseeable future. I want to encourage you to continue your great writing, have a nice weekend!

I know this web site offers quality based articles or reviews and other information, is there any other site which offers these kinds of information in quality?

I like the helpful info you provide in your articles. I’ll bookmark your weblog and check again here frequently. I am quite sure I will learn many new stuff right here! Good luck for the next!

You’re so cool! I do not suppose I’ve truly read something like this before.

So good to discover another person with original thoughts on this subject matter. Really.. thank you for starting this up. This website is something that is required on the web, someone with a little originality!

Nice post. I was checking continuously this blog and I’m impressed! Extremely helpful info specifically the last part :) I care for such information a lot. I was looking for this certain info for a very long time. Thank you and good luck.

I blog frequently and I seriously appreciate your content.

This great article has really peaked my interest. I will bookmark your blog and keep checking for new details about once per week. I opted in for your RSS feed as well.

I think this is among the most important info for me. And i am glad reading your article. But wanna remark on some general things, The web site style is wonderful, the articles is really nice : D. Good job, cheers

Hey There. I found your blog using msn. This is a really well written article. I’ll make sure to bookmark it and come back to read more of your useful information. Thanks for the post. I’ll definitely return.

I simply could not leave your website before suggesting that I really enjoyed the standard information a person supply on your guests? Is going to be back regularly in order to inspect new posts

Hey There. I found your blog using msn. This is a really well written article. I’ll be sure to bookmark it and come back to read more of your useful information. Thanks for the post. I’ll certainly comeback.

Oh my goodness! Incredible article dude! Thank you, However I am having difficulties with your RSS. I don’t know why I am unable to subscribe to it. Is there anybody else having the same RSS issues? Anyone that knows the solution will you kindly respond? Thanks!!

Hello just wanted to give you a quick heads up and let you know a few of the pictures aren’t loading correctly. I’m not sure why but I think its a linking issue. I’ve tried it in two different browsers and both show the same results.

Descargar facebook It’s very trouble-free to find out any matter on net as compared to books, as I found this paragraph at this web site. Descargar facebook

My partner and I stumbled over here coming from a different page and thought I might check things out. I like what I see so now i am following you. Look forward to going over your web page yet again.

I was wondering if you ever considered changing the layout of your blog?

Its very well written; I love what youve got to say.

But maybe you could a little more in the way of content so people could connect with it better. Youve got an awful lot of text for only having one or two images. Maybe you could space it out better?

Hey there! I realize this is sort of off-topic however I had to ask.

Does building a well-established blog such as yours take a large amount of work?

I’m brand new to blogging but I do write in my journal everyday.

I’d like to start a blog so I will be able to share my own experience and feelings online.

Please let me know if you have any suggestions or tips for new aspiring bloggers. Thankyou!

Hey! I’m at work browsing your blog from my new iphone! Just wanted to say I love reading through your blog and look forward to all your posts! Carry on the great work!

This is very interesting, You are a very skilled blogger. I have joined your rss feed and look forward to seeking more of your great post. Also, I have shared your website in my social networks!

I have been surfing online more than three hours today, yet I never found any interesting article like yours. It is pretty worth enough for me. Personally, if all site owners and bloggers made good content as you did, the net will be much more useful than ever before.

Hi I am so excited I found your weblog, I really found you by mistake, while I was researching on Google for something else, Anyhow I am here now and would just like to say thanks a lot for a tremendous post and a all round exciting blog (I also love the theme/design), I don’t have time to go through it all at the minute but I have book-marked it and also added in your RSS feeds, so when I have time I will be back to read much more, Please do keep up the awesome work.

Descargar facebook http://twitter.com/descargar_hq descargar facebook I always spent my half an hour to read this web site’s posts daily along with a cup of coffee. Descargar facebook http://twitter.com/descargar_hq descargar facebook

Excellent post. Keep posting such kind of info on your blog. Im really impressed by your blog. Hello there, You’ve performed a fantastic job. I’ll certainly digg it and individually recommend to my friends. I am confident they will be benefited from this web site.

Link exchange is nothing else but it is simply placing the other person’s weblog link on your page at appropriate place and other person will also do same for you.

Hey there I am so glad I found your blog, I really found you by error, while I was searching on Aol for something else, Regardless I am here now and would just like to say thanks for a tremendous post and a all round enjoyable blog (I also love the theme/design), I don’t have time to read it all at the minute but I have book-marked it and also added your RSS feeds, so when I have time I will be back to read more, Please do keep up the great jo.

Quest bars cheap fitnesstipsnew1 quest bars cheap 516999410492780544 quest bars cheap I constantly emailed this blog post page to all my associates, for the reason that if like to read it afterward my links will too. Quest bars cheap fitnesstipsnew1 quest bars cheap 516999410492780544 quest bars cheap

Great site you’ve got here.. It’s difficult to find good quality writing like yours these days. I truly appreciate individuals like you! Take care!!

Hey there! Do you know if they make any plugins to assist with SEO? I’m trying to get my blog to rank for some targeted keywords but I’m not seeing very good success. If you know of any please share. Many thanks!

Quest bars cheap fitnesstipsnew1 quest bars cheap 516999410492780544 quest bars cheap Thank you a bunch for sharing this with all of us you actually recognise what you’re speaking approximately! Bookmarked. Kindly also visit my website =). We can have a link alternate agreement among us quest bars cheap fitnesstipsnew1 quest bars cheap 516999410492780544 quest bars cheap

Descargar facebook http://twitter.com/descargar_hq descargar facebook If some one wants to be updated with newest technologies after that he must be go to see this web page and be up to date daily. Descargar facebook http://twitter.com/descargar_hq descargar facebook

Wow, fantastic blog layout! How long have you been blogging for? you make blogging look easy. The overall look of your site is great, as well as the content!

Hi there, I do believe your website could possibly be having browser compatibility issues. When I take a look at your blog in Safari, it looks fine however, if opening in Internet Explorer, it’s got some overlapping issues. I just wanted to give you a quick heads up! Aside from that, excellent website!

We are a group of volunteers and opening a new scheme in our community. Your web site provided us with valuable information to work on. You’ve done an impressive job and our entire community will be thankful to you.

Write more, thats all I have to say. Literally, it seems as though you relied on the video to make your point. You definitely know what youre talking about, why waste your intelligence on just posting videos to your blog when you could be giving us something informative to read?

Hi! I understand this is sort of off-topic but I needed to ask. Does managing a well-established blog like yours take a large amount of work? I am brand new to operating a blog but I do write in my diary everyday. I’d like to start a blog so I can share my personal experience and thoughts online. Please let me know if you have any kind of suggestions or tips for new aspiring blog owners. Appreciate it!

نظر خود را بنویسید

ایمیل شما منتشر نخواهد شد. فیلد های الزامی *

در حال بارگذاری...