GithubHelp home page GithubHelp logo

packtpublishing / learn-python-programming-third-edition Goto Github PK

View Code? Open in Web Editor NEW
96.0 9.0 86.0 745 KB

Learn Python Programming 3E. Published by Packt

License: MIT License

Python 45.47% JavaScript 0.07% HTML 1.42% Shell 0.03% Jupyter Notebook 52.94% CSS 0.07%

learn-python-programming-third-edition's Introduction

Learn Python Programming 3rd Edition

Welcome to Learn Python Programming, 3rd Edition.

Here you can find the complete source code for this book. Every line of code you will find in the book is in this repository, plus all the code that we couldn't fit in the book.

Working on a chapter

We suggest you create a dedicated virtual environment for each chapter you wish to work on. Chapters that require third-party libraries will have a folder inside, called requirements.

First you will need to create a virtual environment. If you don't know what a virtual environment is, please read Chapter 1.

Let's now pretend you want to work on Chapter 12. First, change into the folder for Chapter 12 (it's called ch12):

$ cd ch12

Then, create a virtual environment. In this example the virtual environment will live inside the chapter's folder, but you can choose any other folder that might suit you better.

$ python3.9 -m venv .venv

We have given the virtual environment folder the name .venv. Feel free to choose any other name that you might want.


Note: the above procedure might fail in some of the chapter folders, due to the presence of files that aren't meant to be run. If that is the case, you should choose another folder where to place your virtual environment. You can create one within the chapter folder itself, or place the virtual environment outside of the chapter folder altogether.


Next step is to activate the virtual environment:

$ source  .venv/bin/activate

If you're on Windows, to activate your environment, you will need to run:

$ .venv\Scripts\activate

Next, if the requirements folder is present, change into it, and run the following command for each of the .txt files you will find in it. Normally there is only a requirements.txt file.

$ cd requirements
$ pip install -U -r requirements.txt
$ cd ..  # this brings you back to the root of the chapter

Once you have installed all requirements, you are ready to run the chapter's code. If a chapter needs extra work to be set up, you will find all the instructions you need in the chapter's text.

Note: Always remember to activate the virtual environment before you install third-party libraries.

Download a free PDF

If you have already purchased a print or Kindle version of this book, you can get a DRM-free PDF version at no cost.
Simply click on the link to claim your free PDF.

https://packt.link/free-ebook/9781801815093

learn-python-programming-third-edition's People

Contributors

adii1823 avatar gianchub avatar namratakpackt avatar packt-itservice avatar packtutkarshr avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

learn-python-programming-third-edition's Issues

Virtual environment with venv works, but only in parent folders. Why?

Hello,

I'm working through "Learn Python Programing 3rd ed." and I've got to the second chapter. I've got a few years of R programming under my belt but python is new to me, and I'm a little green working on the command line for protracted periods. I'm trying to make a Virtual environment for the chapter using this script in Command-Line using Windows 11 OS:

...\ch02>python -m venv Ch2.venv

but get this error message:

Error: Command '['C:\Users\my_name\Documents\LearnPython\my-project\Learn-Python-Programming-Third-Edition\ch02\Ch2.venv\Scripts\python.exe', '-Im', 'ensurepip', '--upgrade', '--default-pip']' returned non-zero exit status 1.

The Virtual environment folder tries to set up but only gets halfway. There is no activate script to run in the created folder. Pip scripts aren't there either.

The thing is, when I try to create a virtual environment in my folder:

C:\Users\my_name\Documents\LearnPython\my-project\

using the same command, the virtual environment is created without problem.

Could the issue be that a virtual environment exists in this parent folder with its own python installation?

When I ask at either level:

where python

I get:

C:\Users\my_name\AppData\Local\Programs\Python\Python310\python.exe

C:\Users\my_name\AppData\Local\Microsoft\WindowsApps\python.exe

I suspect that it has something to do with trying to install pip and failing. I am following the instructions on the Read_me and so I'm a little confused as to why this essential step is not working as described.

Thank's for your help.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.