Installing works with easy_install but not pip for dogstatsd-python library - pip

Installing library dogstatsd-python works using easy_install, but does not work using pip (in a virtual environment on Mac OS X)
Using easy_install:
$ easy_install dogstatsd-python
... (lot of output)
$ ls -alrt venv/lib/python2.7/site-packages/ | grep statsd
dogstatsd_python-0.5.2-py2.7.egg
Using pip:
$ pip install dogstatsd-python
Downloading/unpacking dogstatsd-python
Downloading dogstatsd-python-0.5.2.tar.gz
Running setup.py egg_info for package dogstatsd-python
Installing collected packages: dogstatsd-python
Running setup.py install for dogstatsd-python
Successfully installed dogstatsd-python
Cleaning up...
$ ls -alrt venv/lib/python2.7/site-packages/ | grep statsd
statsd.pyc
statsd.py
dogstatsd_python-0.5.2-py2.7.egg-info
Pip installed the .egg-info file, and then put the python files directly in the site-packages directory? (Note that the statsd.py file was not installed in any dogstatsd-python directory, but in the site-packages directory itself)
Is this an issue with the library or am I doing something wrong?
I have the following versions installed:
distribute 0.7.3
pip 1.4.1
setuptools 12.0.3
EDIT:
Here's the issue this is causing. The dogstatsd-python library works with the statsd libray.
Using pip:
$ pip install statsd
$ pip install dogstatsd-python
>>> from statsd import statsd
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: cannot import name statsd
Using easy_install:
$ pip install statsd
$ easy_install dogstatsd-python
>>> from statsd import statsd
>>>
More info: https://github.com/DataDog/dogstatsd-python

dogstatsd and statsd conflict. Both end up installing a top-level statsd module. You can install https://pypi.python.org/pypi/dogstatsd-python-fixed/0.5.0 to move dogstatsd to a different name:
% pip install dogstatsd-python-fixed
% python
>>> from dogstatsd import statsd
>>>

Related

unable to load torchaudio even after installing

I'm trying to use torchaudio but I'm unable to import it. I have installed it and it is also visible through the pip list.
<ipython-input-6-4cf0a64f61c0> in <module>
----> 1 import torchaudio
ModuleNotFoundError: No module named 'torchaudio'
pytorch-lightning 1.2.0
torch 1.10.1
torchaudio 0.10.1
torchvision 0.11.2
WARNING: You are using pip version 21.1.2; however, version 21.3.1 is available.
You should consider upgrading via the '/usr/bin/python3 -m pip install --upgrade pip' command.
Since you are using linux and CPU, you should consider uninstalling every pytorch related packages and re-install them via:
pip3 install torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/cpu
as shown here.
I was stuck with the same error. Tried a lot of ways to install and use torchaudio.
This was worked for me (after uninstalling existing torchaudio):
import os
!git clone https://github.com/pytorch/audio.git
os.chdir("audio")
!git checkout 632ea67
!python setup.py install

'scipy' seems to be installed but can not be imported

Here is the error I am receiving when running python 3.10.1 in my terminal.
import scipy
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'scipy'
I used
pip3 install scipy
and everything seemed to work. If I run it again I receive this
pip3 install scipy
Requirement already satisfied: scipy in /usr/local/lib/python3.9/site-packages (1.8.0)
Requirement already satisfied: numpy<1.25.0,>=1.17.3 in /usr/local/lib/python3.9/site-packages (from scipy) (1.22.3)
I also tried
brew install scipy
and that too seemed to work and if I run it again I get this message
brew install scipy
Warning: scipy 1.8.0 is already installed and up-to-date.
To reinstall 1.8.0, run:
brew reinstall scipy
Why wont python3 import scipy?
I ran this in terminal and now everything works
python3 -m pip install scipy
I am still unsure what the original issue was however it may be related to this post here.

basic mlxtend example giving invalid syntax error

I'm using Python 3.5.2 on Ubuntu 16.04.
I've installed sklearn using..
sudo apt install python-sklearn
and mlxtend using...
sudo pip3 install mlxtend
I'm trying to run the basic Iris example found on the Internet, but I am getting an error as soon as I try to import plot_decision_regions from mlxtend.plotting:
from mlxtend.plotting import plot_decision_regions
Traceback (most recent call last):
File "scripts/machine.learning.py", line 6, in <module>
from mlxtend.plotting import plot_decision_regions
File "/usr/local/lib/python3.5/dist-packages/mlxtend/plotting/__init__.py", line 15, in <module>
from .heatmap import heatmap
File "/usr/local/lib/python3.5/dist-packages/mlxtend/plotting/heatmap.py", line 74
raise AssertionError(f'len(row_names) (got {len(row_names)})'
^
SyntaxError: invalid syntax
I had the same error, just upgrade to python3.7 the real error is
python 3.5 does not support f prefix
upgrade using conda
conda install -c anaconda python=3.7
and then update all depencies
conda update --all
I'm not seeing the same error as you, but try remove legend=range(105, 150) from plot_decision_regions i.e.
plot_decision_regions(x_combined, y_combined, clf=tree)
I'm using the latest current sklearn, i.e.
import sklearn
sklearn.__version__
'0.21.3'
Perhaps remove that version
sudo apt-get remove python-sklearn
Then install via pip, i.e.
pip3 install scikit-learn

Pytorch installation issue under Anaconda

I followed the link here to install fastai library using pip install git+https://github.com/fastai/fastai.git
It gave me the following error message. These messages keep the same even I installed Pytorch successfully using conda install pytorch-cpu -c pytorch
and pip3 install torchvision. What can be the reason?
Collecting torch<0.4 (from fastai==0.7.0)
Using cached https://files.pythonhosted.org/packages/5f/e9/bac4204fe9cb1a002ec6140b47f51affda1655379fe302a1caef421f9846/torch-0.1.2.post1.tar.gz
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "C:\Users\shuxi\AppData\Local\Temp\pip-install-7sjptuad\torch\setup.py", line 11, in <module>
raise RuntimeError(README)
RuntimeError: PyTorch does not currently provide packages for PyPI (see status at https://github.com/pytorch/pytorch/issues/566).
Please follow the instructions at http://pytorch.org/ to install with miniconda instead.
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in C:\Users\shuxi\AppData\Local\Temp\pip-install-7sjptuad\torch\
To fix this, do:
$ pip install --upgrade git+https://github.com/fastai/fastai.git
OR
$ pip install --no-cache-dir git+https://github.com/fastai/fastai.git
Your command probably failed because you have installed a old version of torch (0.1.2) some time ago. pip was not supported for torch install for that version and pip instead redirected the user to open pytorch.org in the browser. In your case, pip is reusing this cached package. --upgrade forces pip to choose latest version of all depending packages.

Google Cloud Logging in Python - ImportError

I get the following error when trying to import Google Cloud Logging in Python:
from google.cloud import logging
File "/usr/local/lib/python3.6/site-packages/google/cloud/logging/__init__.py", line 21, in <module>
from google.cloud.logging.client import Client
File "/usr/local/lib/python3.6/site-packages/google/cloud/logging/client.py", line 32, in <module>
from google.cloud.client import ClientWithProject
ImportError: cannot import name 'ClientWithProject'
I have it running in a virtual environment
with this in requirements.txt:
google-cloud-logging>=0.20.0
I was able to get to the next error with:
pip3 install --upgrade google-cloud-logging
for Python 3 and:
pip install --upgrade google-cloud-logging
for Python 2.7
Try to update your google cloud components, run in terminal as admin:
gcloud components update
I had to install dataproc on top of the google-cloud-logging and google-cloud-storage.
Python3
pip3 install mrjob google-cloud-dataproc google-cloud-logging google-cloud-storage
Python2.7
pip3 install mrjob google-cloud-dataproc google-cloud-logging google-cloud-storage

Resources