install python reddit api wrapper module - python

I have downloaded the source in a zip file. I then moved it to /Library/Python/2.6/site-packages/mellort-reddit_api-2d91358. I have been trying to install it with: python setup.py install. This has not worked. I then tried to install it with python /Library/Python/2.6/site-packages/mellort-reddit_api-2d91358/setup.py install, but that would not work as well.
On both occasions it said:
Traceback (most recent call last):
File "/Library/Python/2.6/site-packages/mellort-reddit_api-2d91358/setup.py", line 9, in <module>
open('reddit/__init__.py').read()).group(1)
IOError: [Errno 2] No such file or directory: 'reddit/__init__.py'
I think it cannot find the:
reddit/__init__.py
I have only tried putting the file in the python 2.6 folder.
Any thoughts? If you could provide step by step instructions I would be extremely happy.
I am using mac if that makes a difference.
If you have used this module before (found at https://github.com/mellort/reddit_api) how did you deal with this issue?

You can install it through pip:
sudo apt-get install python-pip python-dev build-essential
sudo pip install reddit -U
update after OP's comments:
for a mac you can do this:
sudo easy_install pip
sudo pip install reddit -U
more info on how to install pip on a mac can be found here.

Related

Error loading MySQLdb module: libmysqlclient.so.20: cannot open shared object file: No such file or directory

I had a running django project and for some reasons I had to remove the current mysql version and install a different MySQL version in my machine.
But now when I am trying to run this program am getting an error as follows:
raise ImproperlyConfigured("Error loading MySQLdb module: %s" % e)
django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module: libmysqlclient.so.20: cannot open shared object file: No such file or directory
reinstall the c shared library:
pip uninstall mysql-python
pip install mysql-python
My issue with the same error message was mysql environment not all the way set up. I needed to uninstall MySQL-python; install libmysqlclient-dev; reinstall MySQL-python to rectify the issue.
So the fix was too:
sudo pip uninstall MySQL-python (uninstall from your package manager of choice)
sudo apt-get install libmysqlclient-dev
sudo pip install MySQL-python
**I should also mention that I used the --no-cache-dir option with pip install to hit PYPI directly which helped discover the following:
sh: 1: mysql_config: not found
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/pip-build-Y7RFpJ/mysql-python/setup.py", line 17, in <module>
metadata, options = get_config()
File "/tmp/pip-build-Y7RFpJ/mysql-python/setup_posix.py", line 43, in get_config
libs = mysql_config("libs_r")
File "/tmp/pip-build-Y7RFpJ/mysql-python/setup_posix.py", line 25, in mysql_config
raise EnvironmentError("%s not found" % (mysql_config.path,))
EnvironmentError: mysql_config not found
and lead me to here
Using: mysql 5.7, mysql-python 1.2.5, django 1.8.9, ubuntu 16.04
Use the following commands:
pip uninstall mysql-python
pip install mysql-python
In my case it work because it searches from the complied files.
I did fix the same issue via setting below environment variable:
export LD_LIBRARY_PATH=/usr/local/mysql/lib
In my case the problem was caused by Ubuntu upgrades, so I can't find libmysqlclient.so.20 in /usr/lib/x86_64-linux-gnu.
Solution:
Check existance libmysqlclient.so.XX in /usr/lib/x86_64-linux-gnu (or similar)
Download libmysqlclient.so.XX from Ubuntu website (eg. link for v20)
Install lib using dpkg command sudo dpkg -i libmysqlclient(...).deb and sudo apt-get install -f
Link lib: ln -s /usr/lib/x86_64-linux-gnu/libmysqlclient.XX.so libmysqlclient.XX.so
just in case pip uninstall & pip install not working, and you dont want to set specific path to ld_library_path, what I did on my vps:
cd /usr/local/lib
sudo ln -s /path/to/your/libmysqlclient.so.20
in my case my mysql is installed from linuxbrew (there is some reason to install inside home), so I had to navigate there $HOME/.linuxbrew/Cellar/mysql/5.7.18/lib/libmysqlclient.so.20
I had the same problem and I fixed making what the mysqlclient official doc says to install before:
sudo apt-get install python3-dev default-libmysqlclient-dev build-essential

pip installation error "No such file or directory: setup.py"

I'm getting installation error because pip couldn't find setup.py.
sudo pip install https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-0.5.0-cp27-none-linux_x86_64.whl
I get this error message.
Downloading/unpacking https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-0.5.0-cp27-none-linux_x86_64.whl
Downloading tensorflow-0.5.0-cp27-none-linux_x86_64.whl (10.9Mb): 10.9Mb downloaded
Running setup.py egg_info for package from https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-0.5.0-cp27-none-linux_x86_64.whl
Traceback (most recent call last):
File "<string>", line 14, in <module>
IOError: [Errno 2] No such file or directory: '/tmp/pip-GdGgbz-build/setup.py'
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 14, in <module>
IOError: [Errno 2] No such file or directory: '/tmp/pip-GdGgbz-build/setup.py'
Can anyone tell me how to solve this problem?
Thanks.
from https://github.com/tensorflow/tensorflow/issues/56
The command to type is "pip install --upgrade pip", and this should be
added to the instructions right after where they tell the user to
"source bin/activate"
Try upgrade protobuf with pip install:
sudo pip install --upgrade protobuf
sudo pip install --upgrade https://storage.googleapis.com/tensorflow/mac/protobuf-3.0.0b2.post2-cp27-none-any.whl
worked for me. The documentation has provided many solutions for various installation problems.
Tensorflow requires python -V 2.7. Since, lot of machine use the stable 2.6 version of python for their system build I would recommend parallel/alternative install of python 2.7. Then you can install pip with 2.7 version python interpreter. Please see below:
#sudo wget https://bitbucket.org/pypa/setuptools/raw/bootstrap/ez_setup.py
#sudo python2.7 ez_setup.py
#easy_install-2.7 pip
#sudo pip install https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-0.5.0-cp27-none-linux_x86_64.whl
I'm using ubuntu 12.04 64bits.
I solve this issue by:
mkdir -p ~/code/download/lib/tensorflow/
cd ~/code/download/lib/tensorflow/
virtualenv --system-site-packages tensorflow_for_ubuntu12_04_64bit_python2_7
source tensorflow_for_ubuntu12_04_64bit_python2_7/bin/activate
cd tensorflow_for_ubuntu12_04_64bit_python2_7
pip install --upgrade tensorflow
the filename you are running sdist with must be named setup.py
running the file as say setup_something.py will fail

How do I fix 'ImportError: cannot import name IncompleteRead'?

When I try to install anything with pip or pip3, I get:
$ sudo pip3 install python3-tk
Traceback (most recent call last):
File "/usr/bin/pip3", line 9, in <module>
load_entry_point('pip==1.5.6', 'console_scripts', 'pip3')()
File "/usr/lib/python3/dist-packages/pkg_resources.py", line 356, in load_entry_point
return get_distribution(dist).load_entry_point(group, name)
File "/usr/lib/python3/dist-packages/pkg_resources.py", line 2476, in load_entry_point
return ep.load()
File "/usr/lib/python3/dist-packages/pkg_resources.py", line 2190, in load
['__name__'])
File "/usr/lib/python3/dist-packages/pip/__init__.py", line 61, in <module>
from pip.vcs import git, mercurial, subversion, bazaar # noqa
File "/usr/lib/python3/dist-packages/pip/vcs/mercurial.py", line 9, in <module>
from pip.download import path_to_url
File "/usr/lib/python3/dist-packages/pip/download.py", line 25, in <module>
from requests.compat import IncompleteRead
ImportError: cannot import name 'IncompleteRead'
I have a Ubuntu 14.10 system.
How can I fix this problem?
While this previous answer might be the reason, this snipped worked for me as a solution (in Ubuntu 14.04):
First remove the package from the package manager:
# apt-get remove python-pip
And then install the latest version by side:
# easy_install pip
(thanks to #Aufziehvogel, #JunchaoGu)
This problem is caused by a mismatch between your pip installation and your requests installation.
As of requests version 2.4.0 requests.compat.IncompleteRead has been removed. Older versions of pip, e.g. from July 2014, still relied on IncompleteRead. In the current version of pip, the import of IncompleteRead has been removed.
So the one to blame is either:
requests, for removing public API too quickly
Ubuntu for updating pip too slowly
You can solve this issue, by either updating pip via Ubuntu (if there is a newer version) or by installing pip aside from Ubuntu.
For fixing pip3 (worked on Ubuntu 14.10):
easy_install3 -U pip
Or you can remove all requests.
For example:
rm -rf /usr/local/lib/python2.7/dist-packages/requests*
On Ubuntu 14.04 I resolved this by using the pip installation bootstrap script, as described in the documentation
wget https://bootstrap.pypa.io/get-pip.py
sudo python get-pip.py
That's an OK solution for a development environment.
The problem is the Python module requests. It can be fixed by
$ sudo apt-get purge python-requests
[now requests and pip gets deinstalled]
$ sudo apt-get install python-requests python-pip
If you have this problem with Python 3, you have to write python3 instead of python.
This should work for you. Follow these simple steps.
First, let's remove the pip which is already installed so it won't cause any error.
Open Terminal.
Type: sudo apt-get remove python-pip
It removes pip that is already installed.
Method-1
Step: 1 sudo easy_install -U pip
It will install pip latest version.
And will return its address: Installed /usr/local/lib/python2.7/dist-packages/pip-6.1.1-py2.7.egg
or
Method-2
Step: 1 go to this link.
Step: 2 Right click >> Save as.. with name get-pip.py .
Step: 3 use: cd to go to the same directory as your get-pip.py file
Step: 4 use: sudo python get-pip.py
It will install pip latest version.
or
Method-3
Step: 1 use: sudo apt-get install python-pip
It will install pip latest version.
Simply running easy_install -U pip resolved my problem.
Check wether you have an older version of requests sitting in your ~/.local/lib/python2.7/site-packages/ and remove it if it is the case (change path to reflect your python version). This solved the issue for me.
My version of pip on ubuntu suggests:
pip install --upgrade pip
In Windows, this worked from an administrative prompt:
Delete C:\Python27\Lib\site-packages\requests*
easy_install requests==2.3
pip install --upgrade pip
pip install --upgrade requests
I tried with every answer avobe, but couldn't make it.
Did this and worked
sudo apt-get purge python-virtualenv
sudo pip install pip -U
After that I just installed virtualenv with pip
sudo pip install virtualenv
I built the virtualenv that I was working on and
the package was installed easily.
Get into the virtualenv by using source /bin/activate
and try to install your package, for example:
pip install terminado
It worked for me, although I was using python2.7 not python3
Check if have a python interpreter alive in any of the terminal windows. If so kill it and try sudo pip which worked for me.
sudo apt-get remove python-pip
sudo easy_install requests==2.3.0
sudo apt-get install python-pip
You can download recent packages manually from these pages:
https://packages.debian.org/fr/stretch/all/python3-pip/download
https://packages.debian.org/fr/stretch/all/python-pip-whl/download
Then, install it by running dpkg:
dpkg -i *.deb
For CentOS I used this and it worked please use the following commands:
sudo pip uninstall requests
sudo pip uninstall urllib3
sudo yum remove python-urllib3
sudo yum remove python-requests
(confirm that all those libraries have been removed)
sudo yum install python-urllib3
sudo yum install python-requests

Install Python-Dbus in virtualenv

I am running an application in a virtual environment that needs access to DBus (to interact with the Network Manager, mainly).
I tried to install Dbus-Python with easyinstall and pip, but both fail.
When I try to do this:
(myvirtualenv)borrajax#borrajax-computer:~/Documents/Projects/VirtualEnvs/current_env$ bin/pip install dbus-python
Pip yells at me with:
Downloading/unpacking dbus-python
Downloading dbus-python-1.1.1.tar.gz (596kB): 596kB downloaded
Running setup.py egg_info for package dbus-python
Traceback (most recent call last):
File "<string>", line 16, in <module>
IOError: [Errno 2] No such file or directory: '/home/borrajax/Documents/Projects/VirtualEnvs/current_env/build/dbus-python/setup.py'
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 16, in <module>
IOError: [Errno 2] No such file or directory: '/home/borrajax/Documents/Projects/VirtualEnvs/current_env/build/dbus-python/setup.py'
----------------------------------------
Command python setup.py egg_info failed with error code 1 in /home/borrajax/Documents/Projects/VirtualEnvs/current_env/build/dbus-python
Storing complete log in /home/borrajax/.pip/pip.log
I have had some issues with the python dbus bindings and their "accessibility" from my Python modules in the past, so I don't really know what may be the best way to set Dbus-Python in a virtual environment. Has anyone successfully achieved this? Or does anyone have an idea on how to do this?
Go to your Venv follow this 2 steps :
sudo apt-get install libdbus-glib-1-dev libdbus-1-dev
pip install dbus-python
verify with:
pip freeze
if installed properly you will see: dbus-python==1.2.8
My suggestion is to install the system package for the Python DBUS bindings and then create the virtualenv with the --system-site-packages command line option to enable access to the system-wide Python packages (including the dbus package) from the activated virtualenv. For example on Debian/Ubuntu (or a derived distribution):
$ sudo apt-get install python-dbus
$ virtualenv --system-site-packages dbus-venv
To use the built in Python 3 venv module instead of virtualenv:
$ sudo apt-get install python-dbus
$ sudo apt-get install python3-venv
$ python3 -m venv --system-site-packages my_venv
When pip tries to install a package, it looks for setup.py, which dbus-python doesn't have, so you'll have to download the source and compile it manually. Shouldn't be too hard:
PYTHON=python3.3 ./configure --prefix=/tmp/dbus-python
make
make install
then you can move the compiled files to your virtualenv.
edit: starting with dbus-python-1.2.2 (released 2016-02-22) dbus-python has a setup.py, so pip should be able to install it
Another workaround is to just manually copy the dbus files/libraries directly to your virtualenv:
cp -r /usr/lib/pythonX.X/{site or dist}-packages/dbus myvirtenv/usr/lib/pythonX.X/site-packages/
cp -r /usr/lib/pythonX.X/{site or dist}-packages/_dbus_*.so myvirtenv/usr/lib/pythonX.X/site-packages/
The OP appears to have opened a ticket on freedesktop.org for this, which remains open; however there is a patch attached to that ticket that could be applied to most any version of python-dbus and then repackaged as a new tarball.
#TheMeaningfulEngineer thank so much, i have being having a few problem to install dbus through pip and that was what i needed i hope you have a good day wherever you are ;)
to check if there is in local - sudo apt list --installed | grep package-name
sudo apt-get install libdbus-glib-1-dev libdbus-1-dev
and after this line I did install dbus and networkmanager without any errors
This is exactly what I did, and before that I checked out all my dbus version and networkmanager after do what #TheMeaningfulEngineer said is working.
For Python as dbus-python is now obsolete, you should be using pydbus:
pip install pydbus
This have worked for me.

How to install mechanize for Python 2.7?

I saved mechanize in my Python 2.7 directory. But when I type import mechanize into the Python shell, I get an error message that reads:
Traceback (most recent call last):
File "<pyshell#0>", line 1, in <module>
import mechanize
ImportError: No module named mechanize
using pip:
pip install mechanize
or download the mechanize distribution archive, open it, and run:
python setup.py install
Try this on Debian/Ubuntu:
sudo apt-get install python-mechanize
You need to follow the installation instructions and not just download the files into your Python27 directory. It has to be installed in the site-packages directory properly, which the directions tell you how to do.
I dont know why , but "pip install mechanize" didnt work for me . easy install worked anyway . Try this :
sudo easy_install mechanize
Here's what I did which worked:
yum install python-pip
pip install -U multi-mechanize
sudo pip-2.7 install mechanize
You need the actual package (the directory containing __init__.py) stored somewhere that's in your system's PYTHONPATH. Normally, packages are distributed with a directory above the package directory, containing setup.py (which you should use to install the package), documentation, etc. This directory is not a package. Additionally, your Python27 directory is probably not in PYTHONPATH; more likely one or more subdirectories of it are.
install dependencies on Debian/Ubuntu:
$ sudo apt-get install python-pip python-matplotlib
install multi-mechanize from PyPI using Pip:
$ sudo pip install -U multi-mechanize
You need to install the python-setuptools package:
apt-get install python-setuptools on Debian-ish systems
yum install python-setuptools on Redhat-ish systems
Use sudo if applicable
It seems you need to follow the installation instructions in Daniel DiPaolo's answer to try one of the two approaches below
install easy_install first by running "easy_install mechanize", or
download the zipped package mechanize-0.2.5.tar.gz/mechanize-0.2.5.zip and (IMPORTANT) unzip the package to the directory where your .py file resides (i.e. "the resulting top-level directory" per the instructions). Then install the package by running "python setup.py install".
Hopefully that will resolve your issue!
pip install mechanize
mechanize supports only python 2.
For python3 refer https://stackoverflow.com/a/31774959/4773973 for alternatives.

Categories