![]() The one that you’ll come across more often is -upgrade. You can even pass various arguments along with it. Installing it would be as simple as pip install requests. As it is a third party module we have to install it separately after installing python. Last time, in import-statements wiki we used requests module as an example. To install modules locally, you need to create and activate what is called a virtual environment, so pip install installs to the folder where that virtual environment is located, instead of globally (which may require administrator privileges). Side note: The difference is that with npm, npm install by default installs packages locally to a project, whereas pip install by default installs globally. If you have used npm, then you can think of it as npm of Python. The simplest way is to use pip pip install So it's time to learn how to install these modules so that we can use those in our programs. Third party modules add so much more functionality to Python. It’s the modules that makes python so powerful! You will *reactivate* your virtual environment(s) every time you need to run code related to this project.Python comes with several built-in modules, but the Python community has more to offer. Notice how I no longer have to use `C:\Python310\python.exe`? (myvenv) python -m pip install pip -upgrade ![]() ![]() `myvenv` is the name of the virtual environment (in this case). Hopefully you see the logic in the fact that if you use Python 2.7 to write a program it *might not* run on Python 3.10 simply because they are different versions.Īs a beginner, this step might *feel pointless* but I promise as your skills grow you will certainly come to appreciate this step.ĭo you see how we used `C:\Python310\python.exe -m` again? Yup, `venv` is a built-in package to Python. **If you write a program using a specific version of Python, it may or may not work using another version of Python.** Technically speaking, this is *definitely* possible but it poses a new problem: Remember how in step 1 we installed the latest version of Python 3.10? What if we wanted our system to use Python 3.6? Or Python 3.8? ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |