I don't know how delete python2 in mac? - python-3.x

I used visual studio in mac air and I install python3.8.5 but already mac has python2
So I can't use python3.8 in visual studio..
I don't know how delete python2 in mac?
plz give me some tips..

You can change the default shell in use selection a new one, you can choose default shell in execution when using visual studio code:
You can customize your shell execution selecting the Select default shell, after you can select your current path to python3.
To discover where is your default python3 installation you can run the command:
which python3
#/usr/local/bin/python3
After that you can configure the default python3 path in your visual studio instance.
just select the terminal and override the terminal.integrated.shell.osx: environment variable.

Related

Visual Studio Code with Python for Windows AND Anaconda

I'm trying to use Visual Studio Code with both Anaconda and Python for Windows.
I have both installed, and I have the visual studio code extensions for both.
But no matter what I do now the Conda Base gets activated -
(base) PS C:\Users
even though the Python for Windows is the selected version
or if I try to activate an environment I get a mix of both, the venv with python for windows and the conda base activated.
(venv_iocparser) (base) PS C:\Users\
The settings.json file in this folder only has python for windows in the 'python.pythonPath'; with no mention of conda, but still activates the conda base.
Does anyone know a good article that walks through setting VSCode up with both? With python for windows as the default?
Thank you!
Had a similar issue. Its most likely since you installed VS Code with Anaconda, for some reason or another it just assumes thats what env you want when starting it.
To get out of it just run $ conda deactivate and then activate whatever env you want after that. I fixed it by changing the PATH for the python to only point at the non-conda versions though. I also had uninstalled it all and reinstalled it all at one point though.

Can I launch az login with cmd rather than PowerShell in Visual Studio Code?

What's the problem I'm having?
I get the following error when running 'az login' from the terminal in Visual Studio code:
/mnt/c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe: Invalid
argument
What's the environment?
I'm running Visual Studio code in Windows 10 (version 1809, OS build 17763. 1158). I'm using Ubuntu 18.04 with WSL 1 and I've set my terminal to use "C:\Windows\System32\bash.exe"
I seem to have problems with PowerShell launching from VS code. Does anyone know if it's possible to configure VS code to use cmd rather than PowerShell when doing an az login? Any other suggestions are welcome. Thanks.
For the Visual Code, you can set the default shell as cmd if you want to use the cmd when you need the terminal. It looks like this:
1.
2.
When you finish these two actions, then you can get the cmd terminal when you want a new one. In this way, the cmd is the default.

How to run a command in Developer command prompt 2019 using Python

I'm trying to do build in Developer Command Prompt of VS 2019 using Python script.
Here is piece of code i'm using:
import os
os.system('start /wait C:/Windows/System32/cmd.exe "msbuild C:/Users/Desktop/Project/Project.sln"')
os.system("pause")
But it is not working.Developer command prompt is appearing for just 1sec and disappearing .
When i took variable to check if command was succesful or not ,it is giving variable result as zero,which means command is successful but i'm not able to see it in Developer command prompt.
result= os.system('start /wait C:/Windows/System32/cmd.exe /k ipconfig')
print (result)
Whereas when i'm trying the same command in windows command prompt it's working fine.
How to run a command in Developer command prompt 2019 using Python
Developer command prompt 2019 is a tool which is integrated into VS2019 IDE and provides environment parameters for various development modules.
However, the CMD.exe does not have these environment variables for these, so you cannot just use CMD.exe directly. Sorry that I am not familiar with python code and script. I suggest you could configure Developer command prompt 2019 into System environment variable PATHand then call cmd.exe which integrates the related variables to build your projects without any errors.
Suggestion
First, if you build your project on another new agent, you should install one of tool from step 1.
1) If you install VS2019 IDE in your local agent,please make sure that your local agent has VS2019 IDE and install the related workload about your project type.
Besides, if you install Build Tool for VS2019, please also install the related workload.
2) set the below path under System environment variable PATH
VS2019 IDE:
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin
Build Tool for VS2019:
C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\MSBuild\Current\Bin
3) Then you can call your python script as you described to build your projects.
Any feedback and concern will be expected.

How do I add a virtual environment to Visual Studio 2019?

I have upgraded from Visual Studio 2017 to 2019 (Community Edition). I also have installed the 'Python development' workload from the Visual Studio 2019 installer.
To add a virtual environment to a Python Project in Visual Studio, I right-click 'Python Environments' within the Python project (in the Solution Explorer View) and choose 'Add Environment...'. I opt for 'Virtual Environment', receiving the message:
"You will need to install a Python Interpreter before creating a virtual environment."
I have installed both the Anaconda 2019.03 and Python 3.7 interpreter, and I have access to both of them in Visual Studio.
The following steps worked for setting VS2019 with Anaconda3 already installed.
In the search bar, search for Add Environment, this brings up the VS Installer. Click the Python tab and you'll see a list of items that can be installed. There should only be a couple of them checked... it is unnecessary to install Python again.
When the Installer completes, open VS2019 and open Options from the Debug menu. If you aren't sure about where to show the "conda" executable path, the easiest way is to go to your "c:\user<usrname>\Anaconda3\Scripts\conda.exe" and select that. If you have already set it in your "Windows Advanced System settings" (yes, this is for Windows... there is probably a similar methodology for Linux) then check your environment variables for the path you've indicated in your environment for Conda.exe. (My choice was to forego the path and use only the IDE.)
Assuming you have Anaconda Navigator, and assuming it is open on Environments (left side), you can create a new environment called venv and it will create a Python environment for VS2019. You may need to activate it with a DOS prompt
conda activate venv
When you set it, VS2019 will spin for a bit while it configures you Python Environment in Visual Studio.
The environment choice in Anaconda3 is known as "base". Visual Studio, without Anaconda, sets up an environment called "venv". You should be able to open the Anaconda Navigator and locate your environment there. Because the venv is a separate environment, updating the base environment to use new tools should not affect VS2019. If nothing else, you can check requirements.txt to see which version is associated with the environment although it is easier to check in the Navigator.
There are some advantages to using VS2019 if you have the Git configured. It will channel your work to your default git location.
The VS2019 configuration will take some time. The time it takes to setup Pycharm setup takes less time but you may find having the environment available in VS2019 worthwhile. I found it kept spinning until I restarted. When I restarted, there were a few additional steps.
Create a Python project - name and create it. In the Solution Explorer (right by default), you'll see a listing for Python Environment. If you created the venv environment in the above step, there will be a clean "venv" environment with only about a dozen python items to choose from. This is a clean environment and easier to control. It will exist side by side in the c:\user<usrname>\Anaconda3\envs folder with your "base" environment. You can tailor your requirements from there. If your project requires new packages, one of the default items is pip.
https://learn.microsoft.com/en-us/visualstudio/python/tutorial-working-with-python-in-visual-studio-step-05-installing-packages?view=vs-2022
From here there is a link to an interactive demo on adding packages: https://learn.microsoft.com/en-us/visualstudio/python/media/environments/install-python-packages-2022.gif?view=vs-2017&viewFallbackFrom=vs-2022
Code below is one way to move files into SQL Server
import sys
import csv
import pandas as pd
import pyodbc
from sqlalchemy import create_engine
import urllib
import matplotlib.pyplot as plt
dtype=np.int64
data1 = pd.read_csv (r'D:\Jsonfile.csv', sep=',', engine='python', encoding = "utf-16")
df2 = pd.DataFrame(data1)
params = urllib.parse.quote_plus("DRIVER={SQL Server};SERVER=MyServer;DATABASE=MyDatabase;Trusted_Connection=yes;")
conn_str = 'mssql+pyodbc:///?odbc_connect={}'.format(params)
engine = create_engine(conn_str)
# create the table
df2.to_sql("Jsonfile", engine)
To make this work on a clean environment you need to add sqlalchemy and a few more. When you type in the sqlalchemy under the PyPI, the top command will be: "Run command: pip install sqlalchemy" which is the correct item to click.
You may want to make note that the preferred method of working with Python is to use Visual Studio Code and the setup is well documented here
How can I set up a virtual environment for Python in Visual Studio Code?
Probably you have found some sort of solution by now.
However I got the virtual environments dialog working after repairing the Visual Studio 2019 installation.
You can repair a Visual Studio 2019 installation running the Visual Studio installer and choosing the repair command from the more button (as shown in the figure below).
This is the breadcrumb that I followed:
Tools > Python > Python Environments > Add Environmemt
Add Environment... is at the top of the panel that opens when you get to > Python Environments
You can also use the 'chord' [<Ctrl> K , <Ctrl> '] to open the 'Python Environments' Panel

How to use pip with Visual Studio Code

I have python 3.6 installed, I have a python extension installed on Visual Studio code but I still can't use pip on Visual Studio code. It says it is not a recognised command. Any help please?
Update: I tried installing pip manually but a file in python2.7 keeps stopping. What's bothersome is that I uninstalled python 2.7 ages ago and I've currently removed every folder with it but python-V still says I have python2.7.6 installed.
I'm on windows 10
I found some solution on this website:
https://pip.pypa.io/en/stable/installing/
If you use Visual Studio Code, you can type the following command:
C:\> py -m pip
If everything is alright, you should see the list of commands, which you can use. They are listed in your terminal, as per below.
I also would advise you to check/select the version of Python you are using:
VSCode: There is no Pip installer available in the selected environment
I am pretty sure your problems of VSCode not finding the correct version of Python will be resolved if you add your ( Python 3.6 installation ) location to the system path.

Resources