How can i make computer read a python file instead of py? - python

I have a problem with installing numpy with python 3.6 and i have windows 10 64 bit
Python 3.6.6
But when i typed python on cmd this appears
Python is not recognized as an internal or external command
I typed py it solves problem but how can i install numpy
I tried to type commant set path =c:/python36
And copy paste the actual path on cmd but it isnt work
I tried also to edit the enviromnent path through type a ; and c:/python 36 and restart but it isnt help this
I used pip install nupy and download pip but it isnt work

Try pip3 install numpy. To install python 3 packages you should use pip3

On Windows, the py command should be able to launch any Python version you have installed. Each Python installation has its own pip. To be sure you get the right one, use py -3.6 -m pip instead of just pip.
You can use where pip and where pip3 to see which Python's pip they mean. Windows just finds the first one on your path.
If you activate a virtualenv, then you you should get the right one for the virtualenv while the virtualenv is active.

Related

Why do I have to use "py" to execute python commands instead of "python"?

I am a newbie in Python and had a problem with installing Python packages on my windows computer.
I installed Python itself and then had to install the packages "Numpy" and "Matplotlib" as well. My teacher told us to do it with the commands:
python -m pip install --upgrade pip
pip install numpy
pip install matplotlib
I managed to install Python but when I run the first command to install pip I got the error message telling me that Python is not found. I found the command py -m pip --version here and it worked. After running it pip got installed and I got the message "pip 22.3 from C:\Users\Kaja\Programs\Python\Python310\lib\site-packages\pip (python 3.10)". I guessed this message means that its working.
I had a similar problem with the commands to install Numpy and Matplotlib. It only worked with this commands
py -m pip install numpy
py -m pip install matplotlib
I searched the internet and found this question telling me to run the command doskey py=python and it did not work. But when I swapped py and python so that the command was doskey python=py I eventually could run my teachers commands.
I checked the windows documentation and they are using the same commands as my teacher. I am very curious to know why I had this problem because on my fellow students computers it worked without the doskey command.
Edit:
Thank you very much #RustyPython.
I checked my environment variables and the path to the python.exe was already there.
Out of curiousity I deleted the python.exe from the path variable and although I did that the commands still worked! Another thing I tried was to remove the doskey macro like discribed in this article but still the commands still run without any errors.
I think its something else.
When you install python on windows it usually comes with the python launcher. This provides a way to easily access all the python versions installed on your computer.
The python launcher uses the py command which access the default python version.
py -0p will show you all the installed versions.
See https://www.infoworld.com/article/3617292/how-to-use-pythons-py-launcher-for-windows.html for more details.
For the python command to work then the relevant directory containing python.exe needs to be added to your user PATH variable.
As has been said looks the the python directory is not on your PATH, but the python launcher is and finds the installed python.exe.
If you want python to work on command line then you'll need to add it to your PATH variable. https://realpython.com/add-python-to-path/#how-to-add-python-to-path-on-windows

Cannot install pip, it cannot get virtalenv

I am trying to install Pip as described here
When I run py get-pip.py I get the following error:
ERROR: pipenv 2018.11.26 requires virtualenv, which is not installed.
And if then i try to run pip -v, it says command not found
I dont know what could be the problem here. I ran the command in command prompt.
Edit: I also tried running command prompt in administrator mode. I am using py synonim for Windows 10
The link you provided says to use python get-pip.py instead of py get-pip.py. Maybe you can try this out.
Try typing this if you have single python version installed installed:
sudo apt install python*-pip
Here * can be either omitted or replaced by python version. Or if you think that you have pip, but it doesn't appear try running it as your current python module:
python* -m pip
As well as above, the * can be either omitted or replaced by python version
did you check if python is in your PATH environment ?
Python 3.8 Installation
and Did you check if you run it in the powershell?
pip Install in Windows 10 with Powershell
check your installation, I made it with a virtual machine.

Installing Jupyter Notebook python package - version confusion

I usually work with pyCharm in which it is really easy to manage different python versions. (I use High Sierra, Mac)
In my settings I can see all of them and addon packages:
To be honest, I don't remember how I installed all of these, a bunch of them through brew though.
Now I am trying to run a Jupyter Notebook in python 3, it's using the python 3 kernel, but I am missing acp package.
So I pip install acp. ok.
The Notebook doesn't see the package. This makes me think it's not installing in the correct python version.
pip3 is not recognised as a command.
brew install python3 -> asks to update python 2 to version 3 (which I don't want).
I am quite confused now as how to intall the packages...
It may be installing with python executable your jupyter is not using.
you can directly install in jupyter shell by allowing python executable your jupyter is using:
import sys
!{sys.executable} -m pip install acp
To check your Python executables, you may open a terminal and type
touch ~/.bash_profile; open ~/.bash_profile
Then you will know which path your python exists in. Make sure to select the same path when you configure your project interpreter. Then you may like to upgrade your pip by typing in a terminal:
$ sudo pip install --upgrade pip
$ alias python=python3
$ python --version
Make sure python version is >3, after which that you may try:
pip3 install acp

Fatal Error Using Pip

I have using Python 3.4 in my machine . I have installed the same machine Python 2.7 and do what necessary in Environment Path . In Python34 folder I have changed python.exe to python3.exe . I can use Python2.7 using python command and Python3.4 using python3 command.But there was an error usin pip :
Fatal error in launcher: Unable to create process using '"C:\Python3.4\python.exe" "C:\Python3.4\Scripts\pip.exe" install'
As you see pip still using python.exe . How can I solve this ?
I'll try to be as clear as I can here, the answer you've linked to in the comments above is specifically asking about being able to run multiple versions of python on the same machine, and being able to specify which version is used to run a script from the command line.
when python 3 is installed two executables are added to c:\Windows\ called py.exe and pyw.exe these are used by default when a python script is invoked by double clicking on it in explorer.
if no other command line arguments are set then these executables look inside the script for the shebang line which looks like #!python2 or #!python3.3 and direct the py (or pyw) executable to use that version of python to run the script, note that this could just be #!python which would use the first version found on the system (oldest first) also note that only 2 significant digits can be used (so you couldn't use #!python3.3.4). If no shebang line is found, the first version of python found will be used.
to use a specific version of python from the command line you would then have a couple of options, firstly you could specify the entire path to the python version you want, e.g. C:\Python33\python.exe scriptname.py or you can use flags.
To use a flag you would call py -3.3 scriptname.py which would call the python 3.3 interpreter and pass it the script as an argument for you.
this prevents you needing to mess about with executable names, by messing with the executable names you are breaking your own pip installation. in short there is no reason you should ever need to rename them.
I have the same error when I install python2.7 and python3.6 in my Window7.
After I rename my python.exe, there was an error using pip.
If your pip is the last version,you have to reinstall your pip use the command python3 -m pip install --upgrade --force-reinstall pip.
If your pip is not the last verison ,you can just upgrade your pip with the command python3 -m pip install --upgrade pip.
NOTE. When you install pip for your python2, you hava to change the command as python2 -m pip install --upgrade --force-reinstall pip.
Hope it works for you~

Python pip is not working

I am using Python 3.4 on Windows 7.
I need to install the six module, I have pip installed on my C.
The problem is, whenever I type pip on my cmd nothing happens.
I made sure that my environment variables are set correctly but I am still facing the problem.
Try adding the pip executable to your path.
Show us your path variable, you can see it by typing this at a cmd prompt:
echo %PATH%
Do you know where pip is actually installed? On my Windows VM it's here:
c:\Python34\Scripts\pip.exe
That would mean you need C:\Python34\Scripts in your path.
Just download this file https://bootstrap.pypa.io/get-pip.py and then run python get-pip.py.
In my case, to know my pip version, I have to do it as follows
py -m pip --version

Categories