Pip Installation Python 3.6.1 - python

I am a beginner in programming with Python. I have installed Python 3.6.1, and when I try to install pip (or any other package), this error appears (both in the command and shell):
install pip
^
SyntaxError: invalid syntax
I tried also with pip -m pip, but nothing, still the same error.
I would be very grateful if you could help me.

To install a Python package, you need to be in the command line as #MohideenibnMohammed suggested. You cannot install a package from within a Python script using pip.
You have installed Python 3.6.1 which will have pip already installed so you don't need to try and install that again.
Next, you need to make sure that Python is added to your PATH.
Open Start Menu and right click My Computer. Click on Advanced System Settings.
Click on Environment Variables
Find the system PATH variable and click Edit. You want to add Python to this PATH variable by adding exactly ;C:\Python36 (assuming that is where you installed Python)
Go back to the command line and type in pip install numpy (you can use pip3 instead of pip if you wish)

I think you are trying to use pip command in python console instead of terminal.
or check your command again .. pip install package
otherwise try this,
use pip3 install package to install instead of pip install package

Related

pip install in python 3.6.5

I'm trying to install some libraries on python, and I open cmd and type-m pip install <lib_name> but it says there's syntax error. When I skip the "<" it says pip is not a recognized command. Any help? I'm using Python 3.6.5.
enter image description here
this is the output for almost every command I'm trying...
first of all we need to know if you are good to go with pip.
Try posting the output of
pip --version
If pip doesn't seem to be installed, you should install it via
python -m ensurepip --default-pip
Once pip is installed you can install packages using the command
pip install whatever
Here's a complete starter pack tutorial for using pip :)
https://packaging.python.org/tutorials/installing-packages/
you can enter either cmd into the terminal:
python -m pip install <package-name>
or
pip install <package-name>
The first will always install into your global environment and the second could depend on whether you're in a virtualenv (if none of this makes sense to you, don't worry about it).
First install python!
According to your screenshot, it is not installed... (or not available, in that case check your PATH in system properties).

Using pip on Windows installed with both python 2.7 and 3.5

I am using Windows 10. Currently, I have Python 2.7 installed. I would like to install Python 3.5 as well. However, if I have both 2.7 and 3.5 installed, when I run pip, how do I get the direct the package to be installed to the desired Python version?
You will have to use the absolute path of pip.
E.g: if I installed python 3 to C:\python35, I would use:
C:\> python35\Scripts\pip.exe install packagename
Or if you're on linux, use pip3 install packagename
If you don't specify a full path, it will use whichever pip is in your path.
Because usually i change my intepreter to run something(i got 2 diff projects with both 2 and 3), i use these solution:
Add path to the environment as usual (of course)
Rename ur python.exe , in my case i want to run python 3 using command python3 on my cmd. So i renamed my python.exe in python3.x directory with python3. Itll works with python 2 ofc.
Then to use pip in both python, i use this command.
python3 -m pip install 'somepackage'
and to run pip on python2
python -m pip install 'somepackage'
This is may not the best solution out there, but i like this one
** WINDOWS **
ref : https://datascience.com.co/how-to-install-python-2-7-and-3-6-in-windows-10-add-python-path-281e7eae62a
In my case, I have Python 2.7 and Python 3.4, with the Python Launcher for Windows.
This is the output when running this commands:
PS C:\> pip -V
pip 9.0.1 from c:\python27\lib\site-packages (python 2.7)
PS C:\> pip3 -V
pip 9.0.1 from C:\Python34\lib\site-packages (python 3.4)
I'll note that in my Python27\Scripts\ directory, I have pip.exe, pip2.exe and pip2.7.exe.
And in my Python34\Scripts\ directory, I have pip.exe, pip3.exe and pip3.4.exe.
So all of these .exe files help you when you have different versions of Python installed at the same time.
Of course, for this to work, you have to have the respective Scriptsdirectries in your Path system enviroment variable.
The answer from Farhan.K will work. However, I think a more convenient way would be to rename python35\Scripts\pip.exe to python35\Scripts\pip3.exe assuming python 3 is installed in C:\python35.
After renaming, you can use pip3 when installing packages to python v3 and pip when installing packages to python v2. Without the renaming, your computer will use whichever pip is in your path.
I would advise against ever calling any pip script directly (nor pip3, pip2.7.exe, anything like that).
Instead, a surefire way is to always prefer the explicit variant of calling pip's executable module for a specific Python interpreter:
path/to/pythonX.Y -m pip somecommand
path/to/venv/bin/python -m pip somecommand
C:\path\to\venv\Scripts\python.exe -m pip somecommand
There are many advantages to this, for example:
It is explicit for which Python interpreter the projects will be pip-installed (Python 2 or 3, inside the virtual environment or not, etc.)
For a virtual environment, one can pip-install (or do other things) without activating it: path/to/venv/bin/python -m pip install SomeProject
Under Windows this is the only way to safely upgrade pip itself path\to\venv\Scripts\python.exe -m pip install --upgrade pip
But yes, if all is perfectly setup, then python3 -m pip install SomeProject and pip3 install SomeProject should do the exact same thing, but there are way too many cases where there is an issue with the setup and things don't work as expected and users get confused (as shown by the many questions about this topic on this platform).
References
Brett Cannon's article "Why you should use python -m pip"
pip's documentation section on "Upgrading pip"
venv's documentation section on "Creating virtual environments": "You don’t specifically need to activate an environment [...]"
I ran across an issue with running pip with absolute path. This might be related to WinPython's installation routine and the order of installing Python 3.6 first, 2.7 second, or Python 3.6 being in the path.
No matter which pip was called, it was activating the 3.6 one:
λ C:\prog\WinPython-64bit-2.7.13.1Zero\python-2.7.13.amd64\Scripts\pip2.exe --version
pip 9.0.1 from C:\prog\WinPython-64bit-3.6.1.0Zero\python-3.6.1.amd64\lib\site-packages (python 3.6)
What finally did the trick was calling pip as a module of the respective python binary:
λ C:\prog\WinPython-64bit-2.7.13.1Zero\python-2.7.13.amd64\python.exe -m pip --version
pip 9.0.1 from C:\prog\WinPython-64bit-2.7.13.1Zero\python-2.7.13.amd64\lib\site-packages (python 2.7)
Hope that might help someone with similar issues.
I tried many things , then finally
pip3 install --upgrade pip worked for me as i was facing this issue since i had both python3 and python2.7 installed on my system.
mind the pip3 in the beginning and pip in the end.
And yes you do have to run in admin mode the command prompt and make sure if the path is set properly.
1-open command prompt and change direction using the command cd C:\Python35\Scripts
2- write the command pip3 install --upgrade pip
3- close the command prompt and reopen it again to return to the default direction and use the command pip3.exe install package_name to install any package you want

Install Numpy in pydev(eclipse)

I am trying to install a package called 'numpy'.
i have python setup in eclipse luna with the help of pydev.
how do i install numpy in pydev.
tried putting numpy in site-packages folder. doesnt seem to work
In Eclipse, Goto Windows->Preferences
Select PyDev->Interpreters->Python Interpreters
Then click on Manage with pip button, then you will see a new window like below, you just need to type your package and click Run/Press enter.
After this, Click Apply and OK, then Right click on Project then click on PyDev->Remove error markers.
Hope it works.
do you have pip installed with your python?
How to install pip
Then if you have your path variable set you can simply type "pip install numpy" into command line.
download the required version of numpy from here http://sourceforge.net/projects/numpy/files/NumPy/1.9.2/
and the install directly ,it will run on eclipse automatically
If it does not solve your purpose use Pip:
pip install numpy
Correct way is to create a virtualenv virtualenv ~/venvs/eclipse, install numpy (source ~/venv/eclipse/bin/activate;pip install numpy), then add the virtualenv to eclipse (see https://www.rose-hulman.edu/class/csse/resources/Eclipse/eclipse-python-configuration.htm)
Pandas can be installed after install python in to your pc.
to install pandas go to command prompt and type "pip install pandas" this command collecting packages related to pandas. After if it asking to upgrade pip or if pip is not recognized by the command prompt use this command:
python -m pip install --upgrade pip.

Trouble with adding pip's system environment variable

I was able to install pip by using distribute_setup.py and get-pip.py. However, I had to add pip to path by adding C:\Python27\Scripts.
This worked for a little while but I had to do a system restore for other reasons and now when I type pip in the command prompt it returns: 'pip' is not recognized as an internal or external command.
I tried adding C:\Python27\Scripts to path again both to the user variable and system variable but to no avail. I also tried re-installing pip but it just said I had the latest version installed already. Pip can be imported without any error within python so I am at a loss here. Can anyone help?
Thanks in advance.
Try using easy_install
easy_install -U pip
This will remove pip.
If you don't have easy_install ... installed, do that first.
After uninstalling pip, simply reinstall it using the get-pip.py file.

Did I install pip correctly?

I'm new to python and the tutorial I'm using suggested for me to install four important packages (distribute, pip, nose and virtual env).
I've installed the first two using setup.py in Windows PowerShell
Problem is I can't figure out how to use pip. I've tried doing commands for pip in the cmd, python idle shell and powershell. All of them return something similar to pip is not defined or there is a syntax error
Here's what i type which results to syntax error
pip freeze
pip list --outdated
Anyone know if I've done something wrong installing pip?
Notes:
I'm using Windows 7
I've checked the Python2.7 directory and pip is in the Scripts folder.
I've also used help("modules") in the Python Idle shell and it lists pip in the modules
To add an answer to this question (it was provided in the comments by Joran Beasley), the issue here was that pip installs to the python/Scipts directory, but that was not in the path by default on Windows. Adding C:\Python27\Scripts to the path fixed the issue. This answer describes adding a directory to the path on Windows 7.
if you've ubuntu you have just to install the pip with aptget
sudo apt-get install python-pip

Categories

Resources