pkg_resources not found while installing java on Mac - python

Traceback (most recent call last):
File "/usr/bin/xattr-2.7", line 7, in <module>
from pkg_resources import load_entry_point
ImportError: No module named pkg_resources
My PYTHONPATH contains /usr/local/lib/python3.7/site-packages, the site-packages folder indeed contains the pkg_resources folder. I tried everything and have spent hours searching stack overflow. I even reinstalled python and setuptools, but nothing seems to work.
The command I am using to install Java - brew cask install java

I guess I was so lost trying to install it with brew, that I forgot that I could download the dmg file from the Oracle website and install it. I still can't figure out the issue with pkg_resources though.

Related

No module named '_gdbm'

I don't know much about python and I need help to install a python software.
I am using linux mint 12.8.
Since I have tried many things I think I have several versions of python installed (3.5 and 3.7 I think...).
When I run setup.py install I get:
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/CommandNotFound/CommandNotFound.py", line 7, in <module>
import dbm.gnu as gdbm
File "/home/zach/10_Soft/anaconda3/lib/python3.7/dbm/gnu.py", line 3, in <module>
from _gdbm import *
ModuleNotFoundError: No module named '_gdbm'
I tried to install python3.5-gdbm (which appears to be up to date) and python3.7-gdbm (which is not found).
They both seem to be virtual packages of the same package python3-gdbm. I don't really know what to do with this information however...
Do you know what I should do?
I was able to solve this issue using this command:
sudo cp /usr/lib/python3.5/lib-dynload/_gdbm.cpython-35m-x86_64-linux-gnu.so /usr/lib/python3.7/lib-dynload/_gdbm.cpython-37m-x86_64-linux-gnu.so

Installing socketio module on python3 seems to be corrupting pip

While installing the socketio package for python using pip3 install socketio, I got the following results:
ERROR: launchpadlib 1.10.13 requires testresources, which is not installed.
WARNING: The scripts easy_install and easy_install-3.8 are installed in '/home/bill/.local/bin' which is not on PATH.
Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
Successfully installed netifaces-0.10.6 setuptools-3.3 socketio-0.2.1
Although I was able to import socketio successfully, pip3 seems corrupted(?).
Specifically, when trying to run anything including pip3, even pip3 by itself in the terminal, I get the same error:
Traceback (most recent call last):
File "/usr/bin/pip3", line 6, in <module>
from pkg_resources import load_entry_point
File "/home/<username>/.local/lib/python3.8/site-packages/pkg_resources.py", line 1479, in <module>
register_loader_type(importlib_bootstrap.SourceFileLoader, DefaultProvider)
AttributeError: module 'importlib._bootstrap' has no attribute 'SourceFileLoader'
Error in sys.excepthook:
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/apport_python_hook.py", line 144, in apport_excepthook
with os.fdopen(os.open(pr_filename,
FileNotFoundError: [Errno 2] No such file or directory: '/var/crash/_usr_bin_pip3.1000.crash'
Original exception was:
Traceback (most recent call last):
File "/usr/bin/pip3", line 6, in <module>
from pkg_resources import load_entry_point
File "/home/<username>/.local/lib/python3.8/site-packages/pkg_resources.py", line 1479, in <module>
register_loader_type(importlib_bootstrap.SourceFileLoader, DefaultProvider)
AttributeError: module 'importlib._bootstrap' has no attribute 'SourceFileLoader'
I tried reinstalling pip3 but it didn't help. I migrated from ubuntu to mint thinking it is something buggy with the distribution but same results. I also corrupted ubuntu when I tried to remove python and reinstall it since I couldn't use pip, but, you know what they say, live and learn.
Edit: Nothing on using pip3: module "importlib._bootstrap" has no attribute "SourceFileLoader" works for me.
I am currently using linux mint 20, but I experienced the same problem on ubuntu 20.04 and 20.04.1.
Any ideas would be appreciated!
Perhaps you meant this socketio instead?: https://pypi.org/project/python-socketio
python3 -m pip install python-socketio
The package literally named "socketio" seems like it may simply be old and unsupported1, while "python-socketio" seems alive and developed 2 3
To that end, it's often valuable to take a look at similar packages and also to watch out for typosquatting et al. when installing packages via pip!
Edit: Martijn Peters makes a good point that this is the socketio you are looking for: https://pypi.org/project/python-socketio
Read on if you need a solution for the original one you posted about.
Summary: pip3 install git+https://github.com/allenmcgehee/socketio-0.2.1-patched
I was able to reproduce this in a docker container running ubuntu:20.04 exactly as you described which gave me some hope that I could help out.
I found that socketio had a dependency for setuptools==3.3 which seemed odd to me, but lines up with why the core functionality of pip was breaking after installing socketio.
I am not sure where this package is maintained as there is no git repo referenced. I did find a Russion website in the PKG-INFO, but I wasn't sure where to go from there...
Here is a version of socketio with a requirement of setuptools>=42 so that nothing gets broken: https://github.com/allenmcgehee/socketio-0.2.1-patched
And finally, here is the single command that should install socketio for you without breaking pip:
pip3 install git+https://github.com/allenmcgehee/socketio-0.2.1-patched
**I am assuming you've already fixed pip.
This happened to me with a different module. My solution was to down-grade the version of pip and the version of the module. So, for you the answer would be to run:
python -m pip install pip== (previous version of your pip)
python -m pip uninstall socketio
python -m pip install socketio==0.2.0

What's the sudo apt-get install command for installing flask-cache?

I can't find it anywhere and pip install is not working for me on Windows bash.
I am using a virtualenv in Windows bash. When I run a python file that has a flask cache import, I get the following error:
Traceback (most recent call last):
File "run.py", line 3, in <module>
from app import app
File "/mnt/c/Users/.../app/__init__.py", line 1, in <module>
from main import *
File "/mnt/c/Users/.../app/main.py", line 2, in <module>
from flask_cache import Cache
ImportError: No module named flask_cache
You need to use pip to install it.
pip install Flask-Cache
Turns out, some of the packages were missing from the requirements file I was given. After several searches, I was able to resolve this by installing flask cache for both python 2.7 and 3 distribution.
I used pip2.7 install PACKAGE_NAME and check the same for pip3 install PACKAGE_NAME in my virtual environment.
For any newbie coders out there, it may be really difficult to get through a problem but you can do it! If you need to seek someone out to help you please reach out to me and we can pair program together and help each other out.
I will NEVER turn you away or think your question is dumb. I know how frustrating dealing with a programming problem on your own is with little to no documentation on an application you're supposed to be supporting.

Mac reinstall Python

I tried to use the Coursera course downloader from here and it worked for few courses but not all. They have recommended to use Python3.X. So I uninstalled Anaconda (version 2) from my Mac and installed Python3.5.1 from Python's website but still the course downloaders did not work as it was using default Python 2.7.
So I deleted Python from /usr/local/lib and now nothing is working. When I do which python it shows ``usr/local/bin/pythonand bothpythonandpython3` runs.
But when I do pip install coursera it throws error as follows:
Traceback (most recent call last):
File "/usr/local/bin/pip", line 5, in <module>
from pkg_resources import load_entry_point
ImportError: No module named pkg_resources
And when I do sudo easy_install pip, I get the following error.
Traceback (most recent call last):
File "/usr/local/bin/easy_install", line 5, in <module>
from pkg_resources import load_entry_point
ImportError: No module named pkg_resources
try Homebrew http://brew.sh/
brew install python3
curl bootstrap.pypa.io/get-pip.py | python3
Your Mac should have Python 2 and Python 3 installed by default. in the terminal "python" will launch Python2, "python3" will launch Python3. With Anaconda you could have just kept the Python 2 version and created an environment for Python 3, http://conda.pydata.org/docs/using/envs.html#managing-environments.
This is the solution you will most likely need, No module named pkg_resources. Setuptools is causing the issue and you will need to wget ez_setup.py. Reinstalling Anaconda will save you a lot of time and pain.

I'm unable to compile Phoenix on OSX (10.6.7)

Using python that's installed by default on OSX, I'm trying to run phoenix
https://en.bitcoin.it/wiki/Phoenix_miner
and I'm getting:
python phoenix.py
import itertools, md5
Traceback (most recent call last):
File "phoenix.py", line 29, in <module>
import minerutil
File "/Users/george/Downloads/phoenix-1.4/minerutil/__init__.py", line 25, in <module>
from RPCProtocol import RPCClient
File "/Users/george/Downloads/phoenix-1.4/minerutil/RPCProtocol.py", line 30, in <module>
from twisted.web.iweb import IBodyProducer
ImportError: cannot import name IBodyProducer
Can anyone advise how to proceed?
You probably have to upgrade your version of Twisted. 11.0 should work; it did for me. Try
sudo easy_install --upgrade twisted
[This assumes that easy_install is going to pick up the system python. If it's in a weird state, try sudo python_version path_to_easy_install --upgrade twisted.]
I installed MacPorts, installed python27 to /opt/local/bin/python, downloaded the Twisted-11.0.0 source, and compiled it using python27. I compiled and installed pyopencl from source as well, and now I can run phoenix.py, on Mac 10.6.6.

Categories