current position:Home>Solve the problem that Django cannot access the local server( )Or the problem that the command line execution (Python 3 runserver does not respond

Solve the problem that Django cannot access the local server( )Or the problem that the command line execution (Python 3 runserver does not respond

2022-04-29 06:22:07Terry_ Neuer

1、 What happened

   I perform python3 runserver The statement command line did not respond . Online deletion First line of code for #!/usr/bin/env python, But it didn't work . The meaning of this sentence should be to tell the operating system to execute this When , Call this path :/usr/bin Under the Python Interpreter . But if you can't find it , The default is to use the one we created for the project Python Environmental Science . So I think , Deleting this should be useless .

2、 A turnaround

   I put python3 runserver Change the sentence to python runserver, There was an immediate response . below , I'll go from beginning to end , I'll show you the process in the form of a screenshot . To configure :Window10、Pycharm、Python3.7、 Default installation Python3.7 Corresponding to version Django Latest version .

3、 technological process

  pytorch It's me. anconada The environment created for this project , The default interpreter in this project . Because I'm directly in pycharm Use the command line , So I don't think it's necessary for Django Configure virtual environment .

3.1 Install well Django package

   The installed version is 3.2.13.

3.2 adopt cmd The operation enters the target directory

   Enter my project for Django Created Directory , establish Django project ——HelloWorld.
   Run the following code , We can find out Django With our HelloWorld project , Enter this directory . Bear in mind ,cmd When running commands, be sure to pay attention to whether your path is correct .

django-admin startproject HelloWorld

 Insert picture description here

3.3 perform python runserver

python runserver

   Wrong report , No problem , Because at least there was a reaction . Read the wrong content carefully , The prompt requires us to perform cmd command :

python migrate

 Insert picture description here

3.4 perform python migrate

   If you don't report an error, ignore this step .

python migrate

 Insert picture description here

3.5 display , Successful connection

   perform :

python runserver

   success ! Shortcut key ctrl+c You can exit the current command line .
 Insert picture description here
   Access the default address of the local host server :
 Insert picture description here

4、 summary

   I also have some knowledge points here , Know what it is and don't know why it is , Welcome to discuss 、 To criticize and correct . I will also supplement from time to time , Share what you know and hear .
   If you read a lot of blogs, it's useless , See me this works . My pleasure .
   Because it's my channel , I want to express my private opinion . Because a lot of technology has been used recently , I especially want to contribute to open source coder Thank you , I firmly Support knowledge payment also Love open source . however , No one has an obligation to serve you for nothing , be neither relative nor friend , There is no truth in the world . Some coders on the Internet don't know the spirit of open source at all, so they burst out , This can only appear Your dish And incompetence rage . Besides , Stop plagiarism , It is also the bottom line of open source and knowledge sharing .
   As a small blogger , Only pay attention to one 's own moral uplift without thought of others , I just hope this blog can help you .

copyright notice
author[Terry_ Neuer],Please bring the original link to reprint, thank you.

Random recommended