I am new to Django and Python having trouble with a Django command.
Before the query, I want to let you know that
1) python is installed in my c drive and the path name is C:\Users\admin67\AppDathea\Local\Programs\Python\Python37
2) The Djangp project is in the D drive and the path name is D://wisdompets
3) My python version is python 3.7.0
In the windows shell I give the command python3 manage.py runserver
However this command is not running in my windows shell. I have tried all combinations such as python370, python37, python 3.7..0 but nothing works and I keep getting the message (see the attachment).
The error traceback that I get in the Windows shell is as below.
The term 'python3' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spe lling of the name, or if a path was included, verify that the path is correct and try again. At line:1 char:8 + python3 <<<< manage.py runserver + CategoryInfo : ObjectNotFound: (python3:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException
Please help me resolve this error.
Thanks & Regards Manish
Your Python PATH variable is not configured properly. Having Django project and Python interpreter in different locations is not the problem here. The CMD will find the python.exe from the PATH variable defined in the system. If it can't find it then it will raise an error.
Please go to PATH in your Environment variables (Right click on This PC > Properties > Advanced System Settings > Environment Variables
And check if that exact path of your python.exe(That you mentioned) is there in your PATH. It likely isn't there and that's the reason you're seeing this error.
To resolve it,
Click on Path variable and edit it. Now add the directory where your Python is installed. i.e "C:\Users\admin67\AppDathea\Local\Programs\Python\Python37" ,
Restart your CMD or PowerShell and Python should now be recognized.
pip also must now be recognized and then 'pip install django==1.11.7' in your cmd, as that is what wisdompets need. If you don't specify the version it will fetch the latest version(Django 2.1 as of now) and entire code will break.
Now in your CMD.
python manage.py runserver
Hope this helps !
Related
Im brand new to django and am wondering if i could get some help, Im working my way through the guide on the django website and have got to the point of starting a new project with ...\> django-admin startproject mysite after running this command in the terminal I get back an error saying
django-admin : The term 'django-admin' is not recognized as the name of a cmdlet,
function, script file, or operable program. Check the spelling of the name, or if a
path was included, verify that the path is correct and try again.
At line:1 char:1
+ django-admin
+ ~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (django-admin:String) [], CommandNotFoun
dException
+ FullyQualifiedErrorId : CommandNotFoundException
Im not a huge fan of the windows terminal and try my best to understand the errors it throws at me but cant. could someone help me out with this please.
Create virtual env first
py -m venv venv
Then activate it by given command
venv\Scripts\Activate
Then install your django by below command
pip install django
after that create your project
django-admin startproject mysite
Check the official docs and guide.
I'm not on windows myself but I reckon that error simply means you did not install Django (or Windows can't find it). Try doing pip install django as #Fiddling Bits mentioned (or pipenv install django if you use pipenv).
The Djangogirls installation guide seems very thorough and also includes instructions for Windows: https://tutorial.djangogirls.org/en/installation/
I have am slightly confused about the local and command prompt in the terminal section of PyCharm. Could someone explain to me what the differences are?
Also, how do i activate my virtual environment from PyCharm, as i need it to run selenium (i placed it in a separate virtual environment). Do I use command prompt or local. I tried using local and when i type activate.bat in my Scripts folder, I come across this error message:
activate.bat : The term 'activate.bat' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1
activate.bat
+ CategoryInfo : ObjectNotFound: (activate.bat:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
Suggestion [3,General]: The command activate.bat was not found, but does exist in the current location. Windows PowerShell does not load commands from the current location by default. If you trust this command, instead type: ".\activat
e.bat". See "get-help about_Command_Precedence" for more details.
PS C:\Users\Jonathan\venvs\automation\Scripts>
Can someone assist me on how i can activate my virtual enviornment via PyCharm?
Yes, you can activate your virtual environment in Pycharm. Pycharm configures an interpreter for each project, and by default uses the system Python interpreter if not otherwise specified. To use the virtual environment's interpreter do the following:
Settings > Project > Python Interpreter
Click on the cog next to the path, and select Add... to add a new interpreter
Select existing environment, and enter the path of the venv
Click OK
After doing this Pycharm will do some indexing, and the next time you run your program it should run using that virtual environment.
I am a very new programmer trying to learn Flask now that I've learned the basics of Python. I am following this tutorial https://www.youtube.com/watch?v=Z1RJmh_OqeA&t=355s ... I am stuck at 5:46.
The tutorial, as well as documentation on several other websites, explains to type in the following command:\env\Scripts\activate.bat for Windows, and they suggest using:source env/bin/activate for Mac.
This is what I get in return:
\env\Scripts\activate.bat : The term '\env\Scripts\activate.bat' is not recognized as the name of a
cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was
included, verify that the path is correct and try again.
At line:1 char:1
+ \env\Scripts\activate.bat
+ ~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (\env\Scripts\activate.bat:String) [], CommandNotFoundEx
ception
+ FullyQualifiedErrorId : CommandNotFoundException
Suggestion [3,General]: The command \env\Scripts\activate.bat was not found, but does exist in the current location. Windows PowerShell does not load commands from the current location by default. If you trust this command, instead type: ".\\env\Scripts\activate.bat". See "get-help about_Command_Precedence" for more details.
Until this point everything else had gone smoothly.This is what I've done leading up to this point:
pip3 install virtualenv
virtualenv env
After running these commands, the tutorial asks me to run the command I'm having problems with.
What options do I have to fix this??
You probably have not set the path variable so the system can't find the Scripts folder. In a typical Python installation on Windows (which you seem to be using), Python is installed under the C drive in Program Files, and inside that directory is the Scripts directory, which is where virtualenv.exe lives.
So you need to open Control Panel, go to System, click on Advanced System Settings, click on Environment Variables, then under USER variables highlight Path, click on Edit, and see if the path to Scripts exists; it'll be something like:
C:\Program Files\Python37\Scripts
If it's not there you need to click New and enter it.
I think you should add . before the \env\... path. This implies that, instead \env\Scripts\activate.bat do .\env\Scripts\activate.
Moreover, you can navigate to the venv\Scripts\ folder and type activate.
copy this term and past your command line in your PyCharm and enter:
.\activate
Apologies if the answer seems obvious. I've installed Python3, Django, Git and an environment for said Python without a hitch. Now I'm unsure as to how I get Django up and running. I implemented a "C:>/workspace/local_sites" folder for my Django projects to be in, as seen below:
local sites folder
But I'm unsure as to where I go from here. Every tutorial I come across appears to be running Django through methods I cannot access since I used PowerShell to install the program rather than CmdPrompt. I just want to create a working, interactive website, that I can store in a folder and come back to whenever I please.
Again, apologies if the answer seems obvious. Thank you for your time.
NOTE:
Tried creating a Django project folder through powershell and the command prompt, both times I received this error:
django-admin : The term 'django-admin' is not recognized as the name of a cmdlet, function, script file, or
operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and
try again.
At line:1 char:1
+ django-admin startproject RottenJournalists
+ ~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (django-admin:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
I'm going trough the book Learn Python The Hard Way and i need to install pip.(ex46,ex47)
So i saved get-pip.py on my computer and in powershell i did :
PS C:\Users\Toto\pip> python Get-pip.py
Downloading/unpacking pip
Installing collected packages: pip
Successfully installed pip
Cleaning up...
but then when i try: PS C:\Users\Toto\pip> pip
i get this error:
pip : The term 'pip' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the s
pelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1
+ pip
+ ~~~
+ CategoryInfo : ObjectNotFound: (pip:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
C:\Python27\Scripts\ is already on my path.
I can't figure this out. If some one could please help me.
note: i'm on windows 8 and this is with python 2.7
Whenever I've installed pip on my Windows machine, it installs to my Python's Scripts folder:
c:\Python34\Scripts
So to get pip to run on the command line, I had to add that path to my PATH environment variable. You can get to those settings by doing the following (assuming Windows 7 or newer):
Right click My Computer and choose Properties
Go to Advanced system settings
Click on the Environment Variables button
Double-click the PATH (or Path) variable listed under System variables
Add c:\Python34\Scripts to the end of the list of other paths making sure that it is separated from the previous entry with a semi-colon
Restart your shell and try running pip. If it still doesn't work, you need to find out where pip got installed. In my Scripts folder, I have a pip.exe file. If you do not, then adding the Scripts folder to your path won't help. You'll have to figure out where it got installed and add that path instead.
You can copy zklib in the odoo server folder and restart the odoo server and it should work.
For windows users If the above solution does not help then make sure your python folder is in the right place to do so, go to the windows search bar and type python then right-click open location folder and copy the path and paste it in the environment variables
for more explanation check the following [link ]: https://www.youtube.com/watch?v=i4yJi-cpwWk
What you have to do is you have to first give your Python path then you have to give your Scripts path.
First delete that Scripts path and now click on new button copy the python path and paste it.
Second , click on the new button and copy the Scripts path and paste it.
Now, I think your problem will be solved.