This question already has answers here:
'pip' is not recognized as an internal or external command
(40 answers)
Closed 2 years ago.
I am a new python user. I downloaded python and VS code and ran a few scripts such as print statements and for loops, and everything seems to be working alright.
However, I want to be able to use packages such as numpy. The way that I understand it, I am supposed to go to my computer's command line and type something in such as "pip install numpy," to get numpy installed. However, I have tried typing in many variations of this phrase into my command line, such as "pip3 install numpy", "python install numpy", and things of this nature. No matter what I type in, I get the message "_____ is not recognized as an internal or external command, operable program or batch file."
I am having trouble even getting my command line to recognize that I have python set up and downloaded... and yet, I can clearly access python in VS code as well as on my computer in general. One possible problem is maybe I am in the wrong directory? But I do not know how to find this out of change to the correct directory. Can someone please tell me what to type in or what I am doing wrong? I am on a windows 64 bit computer.
Thank you so much! :)
There is two step for installing python in windows. If you want to user python in your command line, you have to set a PATH. These can help you:
1- https://geek-university.com/python/add-python-to-the-windows-path/
2- How to add to the PYTHONPATH in Windows, so it finds my modules/packages?
After set PATh, you can use python in your command line. Then you should install pip tool. This link gives you a hand to do that:
1- https://phoenixnap.com/kb/install-pip-windows
After installing python and pip, i recommend you to google about virtualenv. It's a wide used tool for python programming.
Normally you dont need to install numpy. Just use in your code:
import numpy as np
Run the script. If you dont see any errors it is because you already had it.
Related
I know this is a problem that's been asked here before, but I have tried all the solutions I found and not solved it. It's possible I'm not understanding the solutions, but I have tried my best.
I am teaching myself Python and it is slow going, so I don't understand a lot yet. I'm using VSCode as an IDE, Python version 3.10, and Windows 10. I only have the Python extension installed for VSCode. My project files are on a flash drive, D. I replaced a couple folder names with [Default Names] in the text below.
I keep trying to debug/run some code in VSCode and the very first line
import numpy as np
gives me the error
Exception has occurred: ModuleNotFoundError - No module named 'numpy'.
But I know that's not true:
`PS D:\0-Career\Programming\PythonCoding\[ProjectFolder]> py -m pip install numpy
Requirement already satisfied: numpy in c:\users\[UserID]\appdata\local\programs\python\python310\lib\site-packages (1.23.1)`
I tried the solution of going to
environment variables > system variables > "Path" > edit > new >
c:\users\[UserID]\appdata\local\programs\python\python310\
as well as
C:\Users\[UserID]\AppData\Local\Programs\Python\Python310\Lib\site-packages\
and
C:\Users\[UserID]\AppData\Local\Programs\Python\Python310\Scripts\
and I also tried adding a user variable called Python. Nothing appears to have changed as a result of these additions.
Some history if it's helpful:
I first started by installing Python using the Microsoft Store. I used IDLE for a bit, and I used my command line to install pip and numpy. They worked for a little while. I later installed Visual Studio Code IDE. I ultimately have uninstalled the Microsoft Store version and installed the application from the Python site for Windows instead. I have also uninstalled and reinstalled it several times trying to fix my issues, and same for numpy. I also searched my C drive for "python" and burned everything from the past couple days and reinstalled and repaired it out of desperation. No luck.
I have tried to the best of my ability to uninstall everything and reinstall everything to start fresh, because numpy worked ever so briefly early on in IDLE, I think until I had installed the web download version of Python. I don't really understand environment variables, so I'm not sure what I'm doing or if I'm doing that wrong, or what needs to be restarted when I try something new, so it's possible I missed something.
Answers a 10 year old could understand would be appreciated! Or terminology I can easily research for an explanation of how to do it.
Ctrl+Shift+P open Command Palette
choose Python:Select Interpreter
Choose the right interpreter
Go to https://www.lfd.uci.edu/~gohlke/pythonlibs/#numpy
Also Check 64 bit or 32 bit
Download the latest version
and open the location where you downloaded the NumPy module now press the 'SHIFT' key and press right-click on the mouse then a menu will open where you find open PowerShell. open it now PowerShell window opens in the folder now type pip install and the file name and press the TAB button and click enter. then the NumPy module will be installed.
Have Fun
Try adding the variable PYTHONPATH to your system variables and add the following paths to this variable.
C:\PATH_TO_YOUR_PYTHON_INSTALL
C:\PATH_TO_YOUR_PYTHON_INSTALL\DLLs
C:\PATH_TO_YOUR_PYTHON_INSTALL\Lib
C:\PATH_TO_YOUR_PYTHON_INSTALL\Scripts
It should look something like this.
Screenshot of Environment Variables
After you added the variable restart your VS Code and it should work.
I hope this helps.
Windows 10, Python 3.8.5, using Mu 1.0.3. I am trying to install new modules. I just started learning python this weekend so I am pretty clueless. There does not seem to be much online that addresses this problem, unless I just don't know the right words.
I have tried going to command line and entering set PYTHONPATH="[a list of all paths that came up in response to printing sys.path]". The command line seemed to accept this, since it did not give me an error message. But Mu still gives me a
ModuleNotFoundError: no module named "modulename".
I have additionally obtained just the location of the module by typing its name into the shell, and then attempting sys.path.append("path"), in both Mu and the shell. I get the same ModuleNotFoundError.
So, how do I get the code editor to find modules? And, how do I make it a permanent fix?
As per this article the Mu editor has its own Python environment, separate from the one that typical Python installations have
Due to this, to be able to use them on Windows, we have to install our requirements into a specific location:
pip install –r automate-win-requirements.txt --target "C:\Users\USERNAME\AppData\Local\Mu\pkgs"
im trying to install tensorflow on my computer. I have windows 10. Im doing CPU only pip install. When i paste this (pip install --upgrade https://storage.googleapis.com/tensorflow/windows/cpu/tensorflow-0.12.1-cp35-cp35m-win_amd64.whl) command into my command prompt i get error message that says "no perl script found in input". What is the problem? is it referring to Perl programming language or something else? how is perl related to any of this? Thanks!!!
what python version installed in your environment ?
if it's 3.6 you can simply replace the -cp35-cp35m- become -cp36-cp36m-
I hope it'll help
I just ran into the "No Perl script found in input" error myself, in a different situation (as is, not trying to use pip).
The original poster has supplied a comment that answers the question he asked; he had two "pip"s in his path and the wrong one was before the right one. He either had to change the order of his path or supply a full pathname.
This helped me solve my problem; I was using the command line lwp-download to download a file and suddenly got this error. Running lwp-download.bat solved my problem.
If you experience the "No Perl script found in input" error, try running "where" and then your command; in my example "where lwp-download". If you have more than one file in your path with that name, try to be specific. In my case, add the ".bat"
This question already has answers here:
How to install NumPy for python 3.3.5 on Mac OSX 10.9
(3 answers)
Closed 6 years ago.
I'm trying to install Numpy on my mac so i can practice doing some programming for data science. However i have no idea what i'm doing when it comes to downloading software and btw my knowledge of software instillation in general is terrible (i'm more of a pure mathematician). If it isn't as simple as hit download and it works (as it seemed to do with windows) i'm finding myself getting stuck.
I have python 3.5.1 downloaded on my mac. So the book i'm going through at the moment when talking about arrays starts by saying >>>import numpy, in the command prompt. Thinking it would just be as easy as that i tried it, but obviously it wasn't that simple because i haven't downloaded it. Anyway then i looked into downloading numpy, i downloaded a folder in my downloads called numpy.1.11.0 and copied and pasted it into my desktop. I went back to the idle and typed >>>import numpy again, and again it didn't work.
I'm so confused as to what to do now, i've looked at some older posts but they haven't helped, i've also downloaded an open source package called anaconda (something mentioned in the other posts) which i think has everything (data science related) on it but i have no idea how to use it. Do i create python scripts in anaconda? Do i create the scripts before and some how run them in anaconda?
I'd really appreciate any help regarding how to get numpy installed or perhaps how to start using python in anaconda (or both). I've found myself getting lost in all the jargon in the other posts, a simple step by step approach i.e "first click this", "then install this" would probably be best suited to me, if anyone knows where i can find instructions in this form i'd very much appreciate it.
Thanks for the help!
Edit: Thanks to everyone for the help it has been great, in particular i tried pip3 install numpy in the command line. Now i can import numpy in the python idle. If i want to use it in a script file (i'm using text wrangler for this) would i just import numpy as usual?
In addition i started playing around with anaconda and using the spyder package this also let's me run python scripts and allows me to import numpy.
Go to your terminal and run the following command:
pip3 install numpy
If that gives you permission or IO errors try using sudo
sudo pip3 install numpy
This question already has answers here:
python3 --version shows "NameError: name 'python3' is not defined"
(2 answers)
Closed 6 years ago.
I use Windows 7 and Python IDLE.
I'm trying to use easy_install but gut this error:
Traceback (most recent call last): File "", line 1, in
easy_install NameError: name 'easy_install' is not defined
In included in my 'Path' the directory where it has been installed (C:\Python27\Scripts).
Any thoughts on what could be wrong?
Maybe...
In Python IDLE > File > Path browser, I cannot see C:\Python27\Scripts. How to add it ?
Make sure you've done all of this.
Adding Python to Windows Path.
Downloading and installing setuptools for appropriate python version.
Adding Scripts directory (for instance C:\Python27\Scripts) to Windows Path.
You can check installing by opening a command prompt and typing "easy_install"
easy_install is an executable program, not a Python script. Run it from the Windows command line, not from Python.
I once had a similar problem when I was trying to use easy_install. I finally was able to install both easy_install and pip although I really needed just one of them to get the job done.
If you are still struggling with this problem, I would suggest you follow these instructions I put together recently for others who asked me to. It is fairly easy to follow in order to re-install easy_install on your machine. I also explain how to add the directory to your path - which sounds like you have done already but still seeing the above problem. Here is the link that might help you solve this problem.
Simple easy_install installation guide for windows
I hope this helps you get back up and running again! Good luck!