Ex 46: Setting things up

I started working through ex46 using the Windows procedures. I only have Python 3.6 installed. I got to the part where I type pip list and this was the result:

PS C:\Users\dswal\AppData\Local\Programs\Python\Python36\Doug> pip list
Package    Version
---------- -------
pip        18.1
setuptools 40.6.2
You are using pip version 18.1, however version 20.3b1 is available.
You should consider upgrading via the 'python -m pip install --upgrade pip' command.

This has frozen me since I know Python is now at 3.9 but the book is for 3.6 so I’ve stuck with 3.6. Should I do the upgrade as suggested or is it okay to proceed ahead without doing that? I wasn’t sure what I got qualified as a deprecation warning or not and I know the book says I can ignore deprecation warnings.

I figured it was okay and pressed ahead and installed virtualenv however what I got back from Powershell was different than what the book showed…

PS C:\Users\dswal\AppData\Local\Programs\Python\Python36\doug> virtualenv --system-site-packages .venvs/lpthw
created virtual environment CPython3.6.8.final.0-64 in 1449ms
  creator CPython3Windows(dest=C:\Users\dswal\AppData\Local\Programs\Python\Python36\Doug\.venvs\lpthw, clear=False, global=True)
  seeder FromAppData(download=False, pip=bundle, setuptools=bundle, wheel=bundle, via=copy, app_data_dir=C:\Users\dswal\AppData\Local\pypa\virtualenv)
    added seed packages: pip==20.2.4, setuptools==50.3.2, wheel==0.35.1
  activators BashActivator,BatchActivator,FishActivator,PowerShellActivator,PythonActivator,XonshActivator

I’m guessing the discrepancy is due to changes in virtualenv since the book was written? Not sure. But after that I hit a brick wall in Powershell when I tried to activate it…

PS C:\Users\dswal\AppData\Local\Programs\Python\Python36\doug> .\.venvs\lpthw\Scripts\activate
.\.venvs\lpthw\Scripts\activate : File
C:\Users\dswal\AppData\Local\Programs\Python\Python36\doug\.venvs\lpthw\Scripts\activate.ps1 cannot be loaded because
running scripts is disabled on this system. For more information, see about_Execution_Policies at
At line:1 char:1
+ .\.venvs\lpthw\Scripts\activate
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : SecurityError: (:) [], PSSecurityException
    + FullyQualifiedErrorId : UnauthorizedAccess

I’m going to look through the forum and see if someone else ran into this before me and got past it. But in case not, I posted the above.

I guess I should also mention that Avast keeps analyzing my Python executables. It did it when I ran pip and did it again when I ran virtualenv. It let both through after analysis but is this something I should take proactive action on and disable something in Avast or set up some sort of exception?

You have to tell your system that it’s okay to execute scripts, which isn’t allowed by default for security reasons. Follow that link in the error message.

Seriously, the error message even has a link to aid resolution in it that takes you here:

I don’t want to be rude but you need to read the errors and try to work out the issue before asking for help, as Zed states many times.

Go to that link mentioned and it’ll show you how to allow ps1 scripts to run:

Next, you can probably just get rid of Avast. It’s actually better to do the following:

  1. Create a separate account called “admin” and give that account admin rights.
  2. Use this account to remove admin rights on all other accounts. This blocks about 80% of all exploits in Windows.
  3. Remove Avast and just use the Microsoft anti-virus which is more than enough once you disable admin.
  4. Whenever you need admin, you’ll be prompted or can use right-click → Run as admin to access things with administrator.

That’s it. Then no more avast screwing up your computer.