[PYTHON] Where VSCode + venv environment construction got stuck

Overview

When creating a Python virtual environment with VS Code and venv, there were various things that got stuck with Powershell and pip, so I organized them. The specific topic is

is.

Introduction

Until now, when developing with Python, I did not set up a virtual environment. However, recent work has made it necessary to upgrade or lower the version of packages installed with pip. So I decided to make my virtual environment debut.

environment

OS:Windows10 Python:3.7.3 (32bit) Text editor: Visual Studio Code Virtual environment: venv

Work content

https://hachian.com/2019/09/19/vscode_venv/ I proceeded with reference to.

Virtual environment activation doesn't work

Ideally, I want to start the virtual environment smoothly when I open the folder that sets up the virtual environment with VS Code. To activate the virtual environment, you need to execute activate.ps1 in Scripts, but if you do this directly with Powershell,

.\Activate.ps1 :Script execution is disabled on this system, so
 C:~Activate.Unable to read ps1.

I get an error statement. Apparently, to run a script in Powershell, you have to run it as an administrator when you start Powershell. However, this time I'm running Powershell in the terminal that came with VS Code, so it seems impossible to run it as an administrator. .. ..

solution

This site was helpful. https://attakei.net/blog/2019/windows-vscode-venv/index.html When you open a folder with VScode, it seems that you can read setting.json in the .vscode folder in that folder and make various settings. (ignorance) Add the following to setting.json. If something is already written in setting.json, type, at the end of the existing sentence and write it below the line break (how to write a JSON file).

{
  "terminal.integrated.env.windows": {
    "PSExecutionPolicyPreference": "RemoteSigned"
  }
}

You can now activate without any problems.

I can't pip install

I could install numpy and pandas, but I couldn't install tensorflow. I get the following error:

ERROR: Could not find a version that satisfies the requirement tensorflow (from versions: none)
ERROR: No matching distribution found for tensorflow

It seems to be a common error when examined. Upon examination, it seems that older versions of pip may not work. But the pip in my environment is up to date. So, as explained on the following site, I tried to install by directly specifying the URL of the whl file. https://sukota.hatenablog.com/entry/2018/10/24/160521 The numbers in the URL mean the version of Python or the package itself. After confirming that it really exists with PyPI, I tried to put it in with pip,

ERROR: tensorflow_gpu-2.2.0-cp37-cp37m-win_amd64.whl is not a supported wheel on this platform.

I see. I gave up here. I noticed later that Python was a 32-bit version. If you install it from the official HP, it seems that 32bit Python will be installed even if the default is 64bit OS. Perhaps the 64-bit version will accept these packages. (Pytorch couldn't be entered with the same error statement) I will add the situation after making it to the 64-bit version.

Summary

Powershell touches the Windows system itself, and if you want to type commands by hand, Git bash is good. You can do git clone (of course). Also, Python will be a 64-bit version. I'm scared, so if the development I'm doing now has settled down.

Recommended Posts

Where VSCode + venv environment construction got stuck
Python3 + venv + VSCode + macOS development environment construction
A note where a Python beginner got stuck
Effortlessly vscode + venv virtual environment (Windows) memo
VScode environment construction (Windows10, Python, C ++, C, Git)
Django environment construction
Environment construction with VSCode + Remote Container (Go / Application)
DeepIE3D environment construction
Emacs-based environment construction
Linux environment construction
Python environment construction
Python environment construction (Anaconda + VSCode) @ Windows10 [January 2020 version]
Environment construction (python)
django environment construction
CodeIgniter environment construction
python environment construction
Python --Environment construction
Python environment construction
Golang environment construction
python environment construction
Word2vec environment construction
Install Python venv --VSCode --GitHub integration environment on Mac
QGIS3 Python plugin development environment construction with VSCode (macOS)
Environment construction: GCP + Docker
Django project environment construction
Go language environment construction
ConoHa environment construction memo
homebrew python environment construction
PyData related environment construction
Anaconda-4.2.0-python3 environment construction (Mac)
Python development environment construction
YOLO v4 environment construction ①
pyenv + fish environment construction
python2.7 development environment construction
BigGorilla environment construction memo
grip environment construction onCentOS6.5
Anaconda environment construction memo
Golang environment construction [goenv]
Mac environment construction Python
Pyxel environment construction (Mac)
Python environment construction @ Win7
What I got stuck around GUI in WSL python environment
VScode environment construction (on Mac) & graph display in Python (@browser)