Had a friend write some script for me. After about an hour, he declared himself one working on it and sent it to me to complete. So I downloaded Python27 and have been tying to get my head in the game.
My friend used some extra modules in his program and I need to get those up and running before I can see the code running.I've tried following several instructionals with no success.
So I was hoping for some help. My Python directory is where it should be in C:\Python27. I've been trying to use the Python )command line) in order to input the code as given and i keep getting back the same result.
"File " line 1
$pip install requests
SyntaxError: invalid syntax
I am completely lost and starting to get a headache. Please help!
'pip' is a command line program, not a python construct.
Try How do I install pip on Windows?
first to get the pip command on Windows.
You should not use python command line interpreter to install the package.
First, follow this question to install pip on Windows. Then you can directly put the pip install command in your cmd.exe and execute it.
Related
Yes, I'm writing a discord bot. I'm beginner and at the very beginning, but I get to the point.
I have my code here and there, and I really doubt the problem is with the code. (please note if it is) But when I try to run this code, I'm doing 2 commands.
First is python3 bot.py, when i'd try to run it, it simply says Python. I encountered the same in VS Code earlier, and all I did was adding python to environment variables, and it worked perfectly. But in Atom, it doesn't says anything except just the python word.
Second is just python bot.py, when I try it, I get another error:
ModuleNotFoundError: No module named 'discord'
same goes if I do import discord.py
Tried downloading many things, none worked.
Image with original code
Image with python3 error
Image with python error
First of all, if you are new to python programming language, I strongly recommend you to use some kind of virtual environment to separate installed packages of different projects on your system. you could use venv, pipenv, or other virtual enviroments.
This tutorial will help you with virtual enviroments
Secondly from the readthedocs page of the discord.py project, you how see how you can install this module:
You can get the library directly from PyPI:
python3 -m pip install -U discord.py
If you are using Windows, then
the following should be used instead:
py -3 -m pip install -U discord.py
if you read further you can find how to install inside a virtual environment.
You have to install the module in the terminal
pip3 install discord.py
I am trying to open a python script in cmd however, [Errno 2] is popping up! Can anyone help, i've tried everything.. even trying to add the path to the system variables.
Also, for some reason, whenever i enter a basic command like cd, 2 lines are skipped and nothing happens.
Try to open your command line and navigate into the directory where your Python file is located. You can do this by:
cd "<your-path-here>"
Now you can see, that it does not say C:/Nicole/... anymore, but this specified directory.
To ensure that your file is within this folder you can do
dir # suggestion from comment
this will list all files within this folder. If you now do
python snippet.py
it will execute the Python file.
Your problem it's still foggy. Anyway, you must install two python packages:
nltk (as the message 'module nltk not found' suggests)
numpy
To achieve this, use the 'pip' tool from the command prompt:
c:\Users\nicol> pip install nltk
c:\Users\nicol> pip install numpy
Depending on your Python flavour, the command may become
py -m pip install nltk
or a similar one (READ THE DOCS!) or it may use a different way to install packages.
Then, you must fix your snippet by adding these lines:
nltk.download('punkt')
nltk.download('averaged_perceptron_tagger')
nltk.download('universal_tagset')
nltk.download('maxent_ne_chunker')
nltk.download('words')
just after the 'import nltk' statement.
If you plan to have fun with Python, a powerful tool like 'PyCharm' it's a 'must have'. Download it from JetBrains site.
Go to the folder your script is saved and Shift+Right Click and select Open Powershell Here. And run the same command. Or if you really want cmd go to the address bar and type in cmd and run the command there.
This question already has answers here:
'pip' is not recognized as an internal or external command
(40 answers)
Closed 2 years ago.
Im trying to import numpy as np (im using VS2019 as the IDE) and I get the error "No module names 'numpy'". So I tried going to the windows cmd and did pip install numpy and I get the error: "'Pip' is Not Recognized as an Internal or External Command." I tried watching this video, and have located my Python3 folder (I cant find Python27), but there is no pip.exe file in there, so now I don't know what to do. Any help would be much appreciated!
As long as you can run python in cmd you should be able to run python3 -m pip install numpy.
My guess is that you accidentally did not add Python to your PATH. Below is a screenshot of the Python3 installation where there is a checkbox to add it to your PATH.
To check if python is added to your PATH run the following command echo %PATH%. If it is not follow this tutorial to add it to your path.
If you didn't add pip to your system variables, you need to cd to the location of your pip.exe in order to use it.
You should be able to find it in a folder called Scripts.
On of my friends had the same problem. We simply reinstalled python on his Windows 10 laptop and we paid attention to add python to PATH and select an option to install pip with python. This worked pretty much, I think the python Win10 installer is sometimes a little bit to complicated on Win10.
First check if pip is already installed by running this command
pip - - version
If it is installed then change the os path and if not check if python is correctly installed or not by running this command
python - - version
If python is installed then try this command
python get-pip.py
I'm pretty new to the community, and new to python. I know the basics. But now I'm trying to download third party modules via pip but everything I do regarding pip displays an error. I know that pip comes with python seeing as the pip file is there.
I am running python 3.6 and windows 10. I have downloaded pip off the internet also but when I try to run the program it says already downloaded. The first time I ran it it said that it was downloading and successfully downloaded so I'm kind of lost.
Thanks!
Sounds like it's already properly installed. pip is a program called from a system terminal, not from a Python prompt. Open up a command prompt and type pip -h see what happens. If this does not print out the help page on how to use pip, and instead you get an error to the effect of:
"pip" is not recognized as an internal or external command, operable program or batch file
You then need to point Windows where to find the program (pip.exe) by adding your Python scripts folder C:\...\Python36-32\Scripts\ to your environment PATH variable. To do this, open the Start menu and search for "environment variables". Open the dialogue and find one named PATH (case doesn't matter). If it doesn't exist, create it. Edit the value and add the file path to the scripts folder to the end using ; as a separator.
As per your comment, if you are getting an access denied windows error this answer from another question may help you.
You need need to be sure either your powershell is being run as administrator, or by creating a virtual environment.
The Installing Packages docs have a great overview, and instructions.
https://packaging.python.org/installing/#use-pip-for-installing
Ok, so I have been through many of the different fixes, and I still can't get it to work. In python command line I run the
pip install pyinstaller
it gives me a syntax error, so I run the line of code to set my path, and pip is in my scripts, it still doesn't work. I am not sure how to get this to work. pip is installed but it still refuses to install pyinstaller, saying it has a syntax error. Upon looking this up I find you need to set the path, so I do so, but that does not fix the problem, Help would be very nice!
You have to run that command from the command line (the terminal), not the Python interpreter.
You may think if something is written in Python or for Python it must be run from the interpreter. Well, not necessarily. Speaking of pip or easy_install, they must be run from the terminal.