Installing PIP on Windows 10 python 3.5 - python

I just started learning Python, and successfully downloaded Python 3.5. I attempted to download/upgrade PIP 8.1.2 multiple times using get-pip.py, which I ran (successfully I think) but when I attempted to execute python get-pip.py
I got the error code:
File "<stdin>", line 1
python get-pip.py
^
SyntaxError: invalid syntax
I understand that pip is included in python but the pip website requires users to upgrade pip which I don't think I can since any pip commands lead to syntax errors, and do not produce the same output that most tutorial sites show. I have tried to find different ways to fix it, but I can't figure out whats wrong aside from pip not being on the computer in the first place or corrupted. Thank you for your assistance.

You won't need to upgrade pip if you just downloaded python 3.5, go to where you have your Python3.5 file and open the folder Scripts, you will find pip.exe. Open powershell and use the cd command to move to the folder containing pip.exe. From here you can use pip install to get modules.
Open Windows Powershell
PS C:Users\you> cd C:\path\to\scripts\folder\containing\pip
PS C:\path\to\scripts\folder\containing\pip> pip install module

Not sure what you are asking. If you want to run python get-pip.py do it in a windows command prompt, not in the python interpreter. But I do not know why you would want to do that.

You already have pip; there is no need to run get-pip. Upgrading can be done by pip itself.
But the reason you are getting errors is that all these commands, including pip itself, should be run at the command line, not in the Python interpreter.

Related

Have problem to run Python command installed by pip in macOS Terminal

I'm not a Python user, so know little about Python. But I have to install stcgal using pip3 following its official guide.
pip3 install stcgal
However, if I run the installed command in terminal, it says zsh: command not found.
After a long searching, I find it was installed at /Users/myUserName/Library/Python/3.8/bin/. Though I can run the command with that path, it's very inconvenient. I wonder is there any way to run the code in any directory instead having to locate it explicitly?
Try something like this:
python -m stcgal -h
You can create or edit your /Users/yimingliu/.zshrc file (if your macOS is older than macOS Catalina 10.15, then the file is /Users/yimingliu/.bash_profile), and add a line to add the python bin folder to your path:
export PATH=/Users/yimingliu/Library/Python/3.8/bin:$PATH

Python Pip "Fatal Error in Launcher" and other issues with updating pip

I'm trying to install Pyinstaller to my computer using pip to convert a python file into a .exe file. When I try to install it, Command Prompt gives me the following error :
Fatal error in launcher: Unable to create process using
'"c:\python27\python.exe" "C:\Python27\Scripts\pip.exe" install
pyinstaller': The system cannot find the file specified.
I've done some looking online and tried just about everything I've found this far and I'm at a loss. I have tried:
using python - m pip install xxxx
updating pip
reverting back to a previous version of pip
using Command Prompt as an Admin
making sure pip is in my PATH using environmental variables
uninstalling and doing a complete reinstall of python.
Reading other people's questions related to this problem, several people suggested running different lines of code like python -c "import pip.__main__" and python -m pip install pip==9.0.0 and my Command Prompt doesn't do anything, even while running as an admin. I assume that I have something fucked up deep in my files or settings that I didn't even realize I changed, but I can't see it for the life of me. I'd be happy to try any suggestions anyone has. Thanks!
Edit: It seems like there may be something wrong with my Command Prompt? When I try entering python -m venv venv, it doesn't do anything or acknowledge the command.

bad interpreter: No such file or directory when running pip

Whenever I try to run pip (with or without any of the options) I get something like this:
$ pip --version
/usr/local/Cellar/pyenv/1.2.16/pyenv.d/exec/pip-rehash/pip: /Library/Frameworks/Python.framework/Versions/3.7/bin/pip: /usr/local/bin/python3: bad interpreter: No such file or directory
Running which pip however, returns me /Users/jalee/.pyenv/shims/pip which is an expected behaviour.
Not sure why this is happening
python3 -c "print('working')"
print working just fine
I solved this problem by using pip instead of pip3.
"bad interpreter: No such file or directory"
seems to mean that a wrong (not bad) interpreter is being used to interpret a Python file.
In my case, it seems that I was trying to install a Python 2 program with a Python 3 installer. In your case, it looks like you are trying to use a Python 2 version of pip, which processes Python 2 files, to install a Python 3 file.
Your submission indicates that your pip (which may be intended for Python 2) is associated with a Python 3 interpreter. Perhaps you might try uninstalling pip then reinstall it making sure that you get the Python 3 version.
I am currently using miniconda 3 which provides both pip and pip3.

Installing Twitter Python Module

I am trying to install Twitter-Python and I am just not getting it. According to everything I've read this should be easy. I have read all that stuff about easy_install, python setup.py install, command lines, etc, but I just don't get it. I downloaded the "twitter-1.9.4.tar.gz", so I now have the 'twitter-1.9.4' folder in my root 'C:\Python27' and tried running
>>> python setup.py install
in IDLE... and that's not working. I was able to install a module for yahoo finance and all I had to do was put the code in my 'C:\Python27\Lib' folder.
How are these different and is there a REALLY BASIC step-by-step for installing packages?
1) Run CMD as administrator
2) Type this:
set path=%path%;C:\Python27\
3) Download python-twitter, if you haven't already did, this is the link I recommend:
https://code.google.com/p/python-twitter/
4) Download PeaZip in order to extract it:
http://peazip.org/
5) Install PeaZip, go to where you have downloaded python-twitter, right click, extract it with PeaZip.
6) Copy the link to the python-twitter folder after extraction, which should be something like this:
C:\Users\KiDo\Downloads\python-twitter-1.1.tar\dist\python-twitter-1.1
7) Go back to CMD, and type:
cd python-twitter location, or something like this:
cd C:\Users\KiDo\Downloads\python-twitter-1.1.tar\dist\python-twitter-1.1
8) Now type this in CMD:
python setup.py install
And it should work fine, to confirm it open IDLE, and type:
import twitter
Now you MAY get another error, like this:
>>> import twitter
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Python27\lib\site-packages\twitter.py", line 37, in <module>
import requests
ImportError: No module named requests
Then you have to do kinda same steps in order to download the module requests.
Looking at the directory structure you have, I am assuming that you are using Windows. So my recommendation is to use a package manager system such as pip. pip allows you to install python packages very easily.
You can install pip here:
pip for python
Or if you want the windows specific version, there are some pre built windows binaries here:
pip for windows
Doing python setup.py install in IDLE will not work because that is an interactive python interpreter. You would want to call python from the command line to install.
with pip, you can go to the command line and run something like this:
"pip install twitter-python"
Not all python packages are found with pip but you can search using
"pip search twitter-python"
The nature of pip is that you have to type out the exact name of the module that you want.
So in a nutshell, my personal recommendation to get python packages installed is:
Install pip executable
Go to the command line
Type "pip search python_package"
Find the package you want from the list.
Type "pip install python_package"
This should install everything without a hitch.
Installing Python Modules clearly states you need to install the packages from command line, not the Python interpreter IDE (like IDLE):
For Windows, this command should be run from a command prompt window
(Start ‣ Accessories):
setup.py install
You mention the python setup.py install command, which intends calling python interpreter already and wouldn't make sense to run within interpreter.
You need to set the Windows system path variables to include c:\Python27 and C:\Python27\Scripts.
You do not need to set PYTHONPATH nor use any bat files.
Path c:\Python27 will tell Windows where python.exe is
Path c:\Python27\Scripts will tell Windows where pip is
Run pip from Windows command line (do not use Idle)
Basically, with python3.4.3, you just have to do two things to be able to use twitter:
1.python -m pip install -U pip
then once pip is updated (as it comes preinstalled). you do the second step:
2. pip install twitter
this will install twitter package.
Today, after using pre method, I could not use it again (as per my post yesterday). So I tried another way that's simple and cool and hope would work always (on my pc at least):
...Python34>cd scripts #command prompt change die where pip is
...Python34\Scripts>pip install fabric #in this dir, use pip
Awesome (for me at least) although the package I wanted could not be 'perfectly' installed, yet another pythovery.

How to use pip with multiple instances of python

I recently installed python3 only to realize that mysql-python as well as many other modules were not well supported with it yet. So I changed the path in my bashrc file to point to an installation of python 2.7. The problem is that when I installed python 3 I also installed distribute and pip along with it. I removed the pip and distribute files from the python3 bin directory and installed setuptools and pip using python 2.7 however now when I use the pip command to install django and mysql-python, I get a bash error python331/bin/pip No such file or directory. It's still looking for pip in the python3 install. How can I remedy this?
Thanks
...I get a bash error python331/bin/pip No such file or directory.
It's still looking for pip in the python3 install. How can I remedy
this?
bash, by default, hashes the locations of commands to avoid searching $PATH each time, so if, when you execute...
$ type pip
...you get something like...
pip is hashed (python331/bin/pip)
...you just need to clear the hash table for bash with...
$ hash -r
...then it'll pick up the version in Python 2.7 the next time you try to run pip.
Fixed it.
Renamed the directory of where the python3 was installed, bash automatically looks for the next available python install python 2.7

Categories

Resources