Installing Twitter Python Module - python

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.

Related

python -- manually install downloaded module without admin rights

I am trying to install the python package us without admin privileges.
I have tried pip install us in Anaconda prompt to no avail.
I have also tried the suggestion listed here: Install python modules on windows without admin rights--didn't work.
I have now downloaded the files from the site https://pypi.org/project/us/ to my desktop and need to know how to install the package from here.
I am using the Spyder IDE and Python 3.7. Is there a way to do this?
Thanks.
I do this on the daily and if I understand what you are saying you are doing it right. If pip install us in command prompt or shell (if you are using Windows OS) doesn't work try py -m pip install us. Make sure you are using command prompt and not using your IDEz
As you can see it worked first try for me.
Since you have downloaded the files, Extract them in a folder and normally a setup.py file must be include, open command prompt in that folder and run :
python setup.py install

How to install a new python module on VSCode?

I'm trying to install new python modules on my computer and I know how to install through the terminal, but I wish to know if there is a way to install a new module directly through VSCode (like it is possible on PyCharm)?
I already installed through the terminal, it isn't a problem, but I want to install without be obligate to open the terminal when I'm working on VSCode.
You should open the terminal inside the VSCode and install the modules you want.
something like👇
if that's not you meant, please let me know.
First of all I would advise you to select the current Python version you have. It has been explained here:
VSCode: There is no Pip installer available in the selected environment
Next, you should check is the pip installed in your Python main directory or not, by checking how to do on this website:
https://pip.pypa.io/en/stable/installing/
or this thread
How to use pip with Visual Studio Code
by typing
py -m pip
in your terminal, like
C:\Users\m\Desktop\Python> py -m pip
You should have the list of commands and general options which can be used. One of them is install
On the Python library platform, you always have the command to be copied in order to the installation of package you want.
In your terminal, the initial command should look as:
PS C:\Users\m\Desktop\Python> py -m
to which you should append the command prepared on the Python library platform (by copying it and pasting).
C:\Users\m\Desktop\Python> py -m pip install openpyxl
That's it. The package should be installed in your Python folder, what you will see in the terminal.
If everything is alright, you just need to type
import openpyxl #or other package name, which you downloaded
and use it!
Unfortunately! for now, only possible way is terminal.

Installing PIP on Windows 10 python 3.5

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.

How to install library with pip-console?

I downloaded some python library package (for example uncompile2) from GitHub. How I can install it into Qpython from the directory in my android device with pip-console? Or at least to try install...
You could install it directly through pip console, just type "pip install "
Or, you can make a .sh file with contents
python /your/path/to/the/package/setup.py install
Or at least I think so.
You could copy the modules you want installed into the site-packages folder
using a file manager open up the folder:
/sdcard/com.hipipal.qpyplus/lib/python2.7/site-packages/
that is where you can put the modules, i have not tried it with the pip console.

Matplotlab .exe file for Python 3.4 cannot find path to Python34

I am running Windows and am a beginner python user trying to install a few modules to run a python script. I have Python 2.7.9 and 3.4.2 both installed to the C:\ directory. I downloaded matplotlib-1.4.3.win-amd64-py3.4.exe and the corresponding .exe for python 2.7 from the Matplotlib website, but when I run the py3.4 exe the program cannot find Python 3.4 to update (Cannot install: Python version 3.4 is required, which is not found in the registry).
Python 2.7 installer works perfectly. Is there a misset PATH variable in Windows I can modify so the .exe can function properly? In CMD 'Python --version' returns Python 3.4, so unsure how to fix the issue. I installed these months ago, and may have put them in Downloads before transferring both to C:\ for clarity, which may be the problem but am unsure how to fix it.
Also, if your answer involves pip in any way please clarify how exactly to use pip in Windows. A lot of websites say to run eg. 'pip setup.py install' in the 'terminal' but do not specify if they mean Windows CMD terminal, IDLE GUI, or Python.exe command-line interface. Thanks a lot!
Not the answer to your actual question, but some clarification on your last point:
but do not specify if they mean Windows CMD terminal, IDLE GUI, or
Python.exe command-line interface.
Yes, this requires to know some context that a beginner may not have. The command pip is always used in the CMD terminal. So open CMD, and enter
pip3 install matplotlib
Notes:
Use pip3 when installing for Python 3. Then you're certain you're not accidentally installing libraries for Python 2.
pip setup.py install does not exist. You're mixing up two mechanisms to install Python packages/libraries:
One uses pip, with aforementioned pip3 install <something>. Pip goes looking online, finds a corresponding package name in a database, retrieves the URL for that package, downloads the package and installs the package. All in one command.
python3 setup.py install (again explicitly use python3 or python2 to be sure) requires you to find the package, download it, unzip it, and then in the CMD terminal, inside the unzipped folder, run the python3 setup.py install command.
This second method is usually for the latest-greatest version of a package that is not yet in pip's database, or for packages that never were in pip's database in the first place.
Generally, as a beginner, you want to stick with pip. If you ever run into the issue with the package not being available via pip, you may still be able to use pip for downloading and installing, like for example so:
pip install https://github.com/matplotlib/matplotlib/archive/master.zip
which would install the most recent matplotlib (which won't have even a version number yet, so bugs could be around).
All of these commands happen in the CMD terminal: downloading/installing packages generally all go through the terminal.
Also, when people mention "terminal", they will mean (for Windows) something like the CMD terminal. When it has to be done inside Python, it is generally called the "Python prompt". (IDLE is yet a different beast, that I'm not familiar with. I'm guessing that it has several parts, including a text editor section and a Python prompt section.)

Categories

Resources