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.
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.
OS:Windows10 Python:3.7.3 (32bit) Text editor: Visual Studio Code Virtual environment: venv
https://hachian.com/2019/09/19/vscode_venv/ I proceeded with reference to.
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. .. ..
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 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.
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