VS Code does not see sqlite3 - python

I am building a website using Django and wanted to inspect my database using command: python manage.py dbshell however surprisingly I got CommandError: You appear not to have the 'sqlite3' program installed or on your path. I am using VS Code for my project and got the error in command prompt terminal of VS Code.
I am saying surprisingly because I have already created my models before with commands python manage.py makemigrations and python manage.py migrate. These commands also don't work right now.
It is impossible that sqlite3 is not installed because python installs it inherently. I assume PATH variable is also not an issue as I added it and can run sqlite3 outside of VS Code if I open command prompt from the start menu of windows.
What can be the reason of this corruption/problem and how can I fix it ?
This is screenshot of start menu command prompt :
This is screenshot of VS Code :

Related

Use Python/Django Virtual Environment without MySQL

I'm following this tutorial for beginner Python/Django in VS Code: https://code.visualstudio.com/docs/python/tutorial-django
I ran the following commands in my workspace folder:
py -3 -m venv .venv
.venv\scripts\activate
The first command ran fine, but the second errored out:
'MySQL' is not recognized as an internal or external command, operable program or batch file.
I see many answers for how to solve this online... by installing MySQL. But I don't want to use MySQL in the app I'm building. So, my question is... how do I remove this dependency that seems to have added itself?
Note: I looked in the activate script, and I don't see anything directly referencing MySQL there, so I'm at a bit of a loss as to why it's trying to invoke it at all. Is MySQL just a base dependency of Python?

Unable to Run Python by Code Runner on Visual Studio Code on MacOS

Facing issues with Vsc Code Runner, unable to run python code using Code Runner. Works fine when clicked on Run Python Code button
I get an error
zsh: no such file or directory: /usr/local/bin/python3.9.2
I have identified the error, need to change the run command from
python -u
to
python3 -u
How do I do that?
First, make sure that you have installed the python extension. Secondly, this should be caused by the error of interpreter path recognition. You can modify it manually.
Type ctrl+shift+P and then choose “python:select Interpreter”.
Check that the Python interpreter has selected the correct one, and then run the file again.

Python Fullstack Application - python manage.py runserver - No such file or directory

I have followed this tutorial on Youtube.
First, I think everything was fine etc. but when I want so run the Server with: python manage.py runserver it doesn't work. I got the following error:
bash: /Applications/MAMP/Library/bin/python: No such file or directory
The manage.py file is there and I have tried it several times. I don't know what the problem can be. I have reinstalled python, home-brew, pip and virtualenv
It sounds like you don't have Python installed, or it isn't present in your PATH variables.
In command line try the following
python --version
You should expect to see
python x.x.x
If it isn't included in your PATH variables, you will receive
'python' is not recognized as an internal or external command,
operable program or batch file.
This can be fixed by going to the following
Right click This PC and select Advanced Properties
Click Environment Variables and select Path from the System variables
Click Edit and add Python. It should be at C:\PythonXX, though it would depend on your install directory
And adding Python
If Python is already installed
If Python is already installed, you aren't in the correct working directory. Could you please share your directory tree, including where manage.py is located.

Python stops working on manage.py runserver

I am new to stackoverflow, very new to Python and trying to learn Django.
I am on Windows 10 and running commands from powershell (as administrator).
I am in a virtual environment. I am trying to set up Django.
I have run the following commands
"pip install Django"
"django-admin.py startproject learning_log ."
"python manage.py migrate"
All of the above seemed to work okay, however, when I then try to run the command
"python manage.py runserver"
I get a popup error box that says:
Python has stopped working
A problem caused the program to stop working correctly.
Windows will close the program and notify you if a solution is available.
Can someone tell me how to resolve this issue or where to look for any error messages that might clue me in as to what is causing the problem?
I finally got the "python manage.py runserver" command to work. The only thing different I did was before setting up the virtual env and installing Django was set my executionpolicy to Unrestricted. Previously it had been set to RemoteSigned. I hadn't been gettiing any warning or errors but thought I would try it and it worked.
I encountered the same problem. After trying everything, I switched from PS to cmd, cd to the same directory and run python manage.py runserver. Then it worked. Then I ctrl+C quit the server, switched back to PS, ran the command, it still threw the same dialog window (Python stopped working). Then I went back to cmd, typed the command and the server started fine.
Conclusion: Use cmd to run the command, not PS.

Django -- manage.py shell doesn't work with git bash terminal

So I've been following this django tutorial, and I've been running into some issues with the manage.py commands when using a git bash terminal. I'm using Python 2.7.11 (Anaconda 2.4.1), Django 1.9.5 and git 2.8.1.windows.1 on Windows 10.
Specifically the python manage.py runserver and the python manage.py shell commands don't appear to work properly using a git bash terminal, but they do work when using an Anaconda terminal. I'd like to find a way to get it working with git bash.
According to the tutorial, I should see this output on terminal when running python manage.py runserver:
Performing system checks...
System check identified no issues (0 silenced).
April 19, 2016 - 15:50:53
Django version 1.9, using settings 'mysite.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CONTROL-C.
Using git bash, I know that SOMETHING is working because I can navigate to http://127.0.0.1:8000/ in my browser. I just don't see any output on the terminal.
I continued along with the tutorial, because this didn't really affect anything. It appears to work, just no terminal output. Then I got to this part of the tutorial, where you open a shell with python manage.py shell.
Using git bash, nothing happens. The shell prompt never opens, as if it's stuck. No errors, just a blinking cursor on a new line without a command prompt. If I do the same thing using the Anaconda terminal, the shell opens fine.
At first I thought it was an installation error. So, I attempted to install django using both pip install and conda install, but I still get the same problems. I'm not really sure what's going on here, and I haven't managed to find a solution yet.
Any help is greatly appreciated.
Update:
I found a similar question that doesn't quite have a solution, but it recommends using pystuck to debug. I read the pystuck docs but don't quite understand how to use it for this problem in particular.
I have this problem too, when running python manage.py runserver the verbose output is missing, only high level page responses are present. I was using powershell or Git Cmd, that is an option... This fix also resolves issues with using Git Bash to python manage.py makemigrations and python manage.py migrate,
Option: Use Git Cmd or powershell.
Temp Fix: Run this command in Git Bash to generate verbose output for this working session: alias python='winpty python.exe'
Perm Fix: Use the temp fix in a .bashrc file, git bash will always have verbose output.
cd ~ #Takes you to your root directory.
touch .bashrc
Edit the file using VIM, or editor of your choice, add the following line (note: Notepad from MS Windows will not save this file correctly. Do not use notepad.):
alias python='winpty python.exe'
Restart Git Bash.
Note:
In some circumstances, you will get one prompt when you launch git bash:
"WARNING: Found ~/.bashrc but no ~/.bash_profile, ~/.bash_login or
~/.profile.
This looks like an incorrect setup. A ~/.bash_profile that
loads ~/.bashrc will be created for you."
You will notice a second file .bash_profile was created for you and you are good to go!
That's it... enjoy.
I don't know why but I found a bit of a workaround. When running python manage.py runserver in the Git Bash window on windows 7 (using Anaconda2) I also DID NOT get the expected:
Performing system checks...
System check identified no issues (0 silenced).
February 09, 2017 - 17:39:48
Django version 1.10.5, using settings 'mysite.settings'
Starting development server at http://127.0.0.1:8090/
Quit the server with CTRL-BREAK.
Doing the same in the native windows CMD prompt worked!!!
I had manage.py open in Sublime Text and when I saved it (or any other file in the project) the server (started and currently frozen in the git bash window) started up as expected.
Maybe this will work for you. Don't know why it does or should...

Categories

Resources