Jython ImportError: No module named urllib - jython-2.7

Just installed Jython 2.7beta3 and pip under Jython in mac os x
try to run /usr/local/Cellar/jython/2.7-b3/libexec/bin/pip install requests
Get error:
Traceback (most recent call last):
File "./pip", line 8, in <module>
sys.exit(
File "/usr/local/Cellar/jython/2.7-b3/libexec/Lib/site-packages/setuptools-11.3.1-py2.7.egg/pkg_resources/__init__.py", line 519, in load_entry_point
File "/usr/local/Cellar/jython/2.7-b3/libexec/Lib/site-packages/setuptools-11.3.1-py2.7.egg/pkg_resources/__init__.py", line 2630, in load_entry_point
File "/usr/local/Cellar/jython/2.7-b3/libexec/Lib/site-packages/setuptools-11.3.1-py2.7.egg/pkg_resources/__init__.py", line 2310, in load
File "/usr/local/Cellar/jython/2.7-b3/libexec/Lib/site-packages/setuptools-11.3.1-py2.7.egg/pkg_resources/__init__.py", line 2316, in resolve
File "/usr/local/Cellar/jython/2.7-b3/libexec/Lib/site-packages/pip-6.0.6-py2.7.egg/pip/__init__.py", line 15, in <module>
from pip.vcs import git, mercurial, subversion, bazaar # noqa
File "/usr/local/Cellar/jython/2.7-b3/libexec/Lib/site-packages/pip-6.0.6-py2.7.egg/pip/vcs/__init__.py", line 8, in <module>
from pip._vendor.six.moves.urllib import parse as urllib_parse
ImportError: No module named urllib
I found I can't install anything by pip under jython.
Please help me fix it, thanks.

I had the same problem trying to use pip for Jython2.7b3.
I downloaded this:
https://github.com/jythontools/pip/tree/master
And ran the command:
Jython setup.py install
And pip is now up and running like a charm.

Related

Trying to install powershellempire on Kali Linux but getting a lot of error in pip.I think its a broken module lib has no attribute ERRload RANDstring

I am showing you here, step by step, what I did.
First, I install:
apt install powershell-empire starkiller
It successfully installed. But When I try to run with the server, I receive this error:
> powershell-empire server
Traceback (most recent call last):
File "/usr/share/powershell-empire/empire.py", line 11, in <module>
import empire.server.server as server
File "/usr/share/powershell-empire/empire/server/server.py", line 40, in <module>
from empire.server.common import empire, helpers
File "/usr/share/powershell-empire/empire/server/common/empire.py", line 25, in <module>
from pydispatch import dispatcher
ModuleNotFoundError: No module named 'pydispatch'
I tried to search for this, but it brought up another error.
sudo python -m easy_install --upgrade pyOpenSSL
/usr/bin/python: No module named easy_install
pip uninstall pyopenssl
/usr/local/bin/python: No module named easy_install
I also tried with python3:
sudo python3 -m easy_install --upgrade pyOpenSSL
/usr/local/bin/python3: No module named easy_install
pip2 uninstall pyopenssl
/usr/bin/python: No module named easy_install
Nothing worked, so I try to find solution for easy install
python -m pip install requests
import OpenSSL.SSL
File "/usr/local/lib/python3.10/dist-packages/OpenSSL/__init__.py", line 8, in <module>
from OpenSSL import rand, crypto, SSL
File "/usr/local/lib/python3.10/dist-packages/OpenSSL/rand.py", line 169, in <module>
_lib.ERR_load_RAND_strings()
AttributeError: module 'lib' has no attribute 'ERR_load_RAND_strings'
Back to the first error. This mistake loops. My opensshl lib error comes first, followed by an easy install, and then it comes back. Lib Lib
One more thing is I even not able to show version of pip or pip3
Traceback (most recent call last):
File "/usr/bin/pip3", line 5, in <module>
from pip._internal.cli.main import main
File "/usr/local/lib/python3.10/dist-packages/pip/_internal/__init__.py", line 40, in <module>
from pip._internal.cli.autocompletion import autocomplete
File "/usr/local/lib/python3.10/dist-packages/pip/_internal/cli/autocompletion.py", line 8, in <module>
from pip._internal.cli.main_parser import create_main_parser
File "/usr/local/lib/python3.10/dist-packages/pip/_internal/cli/main_parser.py", line 12, in <module>
from pip._internal.commands import (
File "/usr/local/lib/python3.10/dist-packages/pip/_internal/commands/__init__.py", line 6, in <module>
from pip._internal.commands.completion import CompletionCommand
File "/usr/local/lib/python3.10/dist-packages/pip/_internal/commands/completion.py", line 6, in <module>
from pip._internal.cli.base_command import Command
File "/usr/local/lib/python3.10/dist-packages/pip/_internal/cli/base_command.py", line 18, in <module>
from pip._internal.download import PipSession
File "/usr/local/lib/python3.10/dist-packages/pip/_internal/download.py", line 15, in <module>
from pip._vendor import requests, six, urllib3
File "/usr/local/lib/python3.10/dist-packages/pip/_vendor/requests/__init__.py", line 97, in <module>
from pip._vendor.urllib3.contrib import pyopenssl
File "/usr/local/lib/python3.10/dist-packages/pip/_vendor/urllib3/contrib/pyopenssl.py", line 46, in <module>
import OpenSSL.SSL
File "/usr/local/lib/python3.10/dist-packages/OpenSSL/__init__.py", line 8, in <module>
from OpenSSL import rand, crypto, SSL
File "/usr/local/lib/python3.10/dist-packages/OpenSSL/rand.py", line 169, in <module>
_lib.ERR_load_RAND_strings()
AttributeError: module 'lib' has no attribute 'ERR_load_RAND_strings'

distutils.util missing after upgrading to 3.8

I just upgraded to Pop OS(Ubuntu) 20.04, which upgraded Python 3.7 to 3.8. Now I get this error below when I run sam (from the AWS SAM CLI). Solutions found online all had to do with making sure python3-distutils is installed. I have verified that python3-disutils is installed. /usr/lib/python3.8/distutils looks fine, just not getting picked up for some reason.
One thing I noticed is that in the traceback below, it's using the system-wide pip, while I have a later version of pip installed under my .local. I don't know if those two symptoms are related but looks like I'm missing some config somewhere so none of the 3.8 or user space stuff is picked up.
Build Failed
Error: PythonPipBuilder:ResolveDependencies - Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/usr/lib/python3/dist-packages/pip/_internal/main.py", line 14, in main
from pip._internal.utils.entrypoints import _wrapper
File "/usr/lib/python3/dist-packages/pip/_internal/utils/entrypoints.py", line 3, in <module>
from pip._internal.cli.main import main
File "/usr/lib/python3/dist-packages/pip/_internal/cli/main.py", line 10, in <module>
from pip._internal.cli.autocompletion import autocomplete
File "/usr/lib/python3/dist-packages/pip/_internal/cli/autocompletion.py", line 9, in <module>
from pip._internal.cli.main_parser import create_main_parser
File "/usr/lib/python3/dist-packages/pip/_internal/cli/main_parser.py", line 7, in <module>
from pip._internal.cli import cmdoptions
File "/usr/lib/python3/dist-packages/pip/_internal/cli/cmdoptions.py", line 19, in <module>
from distutils.util import strtobool
ModuleNotFoundError: No module named 'distutils.util'
I have the same issue on Debian Bullseye (or rather mixed Bullseye/Buster).
Package python3-distutils (3.8.6) contains module for Python 3.8 and 3.9 (!).
Old package (3.7.3) for Python 3.7. You have to choose.
My workaround is just copy module.
mkdir -p /usr/lib/python3.7/distutils
cp -a /usr/lib/python3.8/distutils/* /usr/lib/python3.7/distutils/

unable to run a python file because of Module not found error despite sourcing the pythonpath

I have been trying to run a python file using rosrun command but unfortunately I am having this module not found error because of a package named rospkg. Until a day before yesterday, it was all working fine but yesterday, ubuntu18.04 has got some updates out of which an update for ubuntu base was also present, since that update I am having this error.
I have tried to check whether I have installed the respective python-rospkg and its says I already have the latest version. I have also using
echo $PYTHONPATH
to check the sourced paths and they are sourced correct, I am not sure whats causing this error.
the error is as follows
Traceback (most recent call last
File
"/home/microbot/catkin_ws/src/spider/spider_control/control.py",
line 5, in <module>
import roslib
File "/opt/ros/melodic/lib/python2.7/dist-
packages/roslib/__init__.py", line 50, in <module>
from roslib.launcher import load_manifest
File "/opt/ros/melodic/lib/python2.7/dist-
packages/roslib/launcher.py", line 42, in <module>
import rospkg
ModuleNotFoundError: No module named 'rospkg'
The shebang for my is as follows,
#!/usr/bin/python3
When i try to run the file by changing the shebang to
#!/usr/bin/python2.7
I get the following error
Traceback (most recent call last):
File
"/home/microbot/catkin_ws/src/spider/spider_control/control.py",
line 3, in <module>
import tensorflow as tf
ImportError: No module named tensorflow
I have installed tensorflow version 1.14 using pip installation. Can anyone please help me solving this error. Thanks in advance
edit:
I have manually tried to set the python path to /usr/lib/python2.7/dist-packages as when I tried to install python-rospkg, it says the its already instaled in that location. Doing that I am having error importing tensorflow and the error is
`Traceback (most recent call last):
File
"/home/microbot/catkin_ws/src/spider/spider_control/control.py", line
3, in <module>
import tensorflow as tf
File "/home/microbot/.local/lib/python3.6/site-
packages/tensorflow/__init__.py", line 22, in <module>
import inspect as _inspect
File "/usr/lib/python3.6/inspect.py", line 41, in <module>
import linecache
File "/usr/lib/python3.6/linecache.py", line 11, in <module>
import tokenize
File "/usr/lib/python3.6/tokenize.py", line 33, in <module>
import re
File "/usr/lib/python3.6/re.py", line 142, in <module>
class RegexFlag(enum.IntFlag):
AttributeError: module 'enum' has no attribute 'IntFlag'
Error in sys.excepthook:`

Cannot use most python apps after updating to Ubuntu 18.04

After updating to Ubuntu 18.04 LTS I can no longer use most Python apps including pip (to install or uninstall). I get the following error in command-line:
Traceback (most recent call last):
File "/usr/local/bin/pip", line 11, in <module> load_entry_point('pip==10.0.1', 'console_scripts', 'pip')()
File "build/bdist.linux-x86_64/egg/pkg_resources/__init__.py", line 572, in load_entry_point
File "build/bdist.linux-x86_64/egg/pkg_resources/__init__.py", line 2755, in load_entry_point
File "build/bdist.linux-x86_64/egg/pkg_resources/__init__.py", line 2408, in load
File "build/bdist.linux-x86_64/egg/pkg_resources/__init__.py", line 2414, in resolve
File "/usr/local/lib/python2.7/dist-packages/pip/_internal/__init__.py", line 42, in <module>
from pip._internal import cmdoptions
File "/usr/local/lib/python2.7/dist-packages/pip/_internal/cmdoptions.py", line 16, in <module>
from pip._internal.index import (
File "/usr/local/lib/python2.7/dist-packages/pip/_internal/index.py", line 15, in <module>
from pip._vendor import html5lib, requests, six
File "/usr/local/lib/python2.7/dist-packages/pip/_vendor/requests/__init__.py", line 86, in <module>
from pip._vendor.urllib3.contrib import pyopenssl
File "/usr/local/lib/python2.7/dist-packages/pip/_vendor/urllib3/contrib/pyopenssl.py", line 46, in <module>
import OpenSSL.SSL
File "/usr/local/lib/python2.7/dist-packages/OpenSSL/__init__.py", line 8, in <module>
from OpenSSL import rand, crypto, SSL
File "/usr/local/lib/python2.7/dist-packages/OpenSSL/SSL.py", line 105, in <module>
SSL_ST_INIT = _lib.SSL_ST_INIT
AttributeError: 'module' object has no attribute 'SSL_ST_INIT'
After Googling the errors it appears that the version of pyopenssl is out of date, but I've tried to manually download an installpyopenssl18 through a TGZ file or through easy_install and neither have worked.
I cannot install/uninstall via pip because I get the above error. Any suggestions? I'd like to avoid having to reinstall Python or even the OS itself.
After trying the manual install of pyopenssl 18 again I noticed the path it was installing to: /usr/local/lib/python2.7/dist-packages
So I went digging in that directory and saw a folder called:
OpenSSL
which was referenced in the error. I renamed this folder and re-installed pyopenssl and the error is cleared. I don't have any issues accessing HTTPS sites so it is possible this is a deprecated module replaced by pyOpenSSL?

python3 path only running google-appengine modules

When running django projects with python3 or installing modules with pip, I am getting google-appengine errors, even if my project is not using google appengine.
When running pip3 freeze I get the following results:
andrew#andrew:~/dev/quickistock$ pip3 freeze
Traceback (most recent call last):
File "/usr/bin/pip3", line 9, in <module>
from pip import main
File "/home/andrew/.local/lib/python3.5/site-packages/pip/__init__.py", line 26, in <module>
from pip.utils import get_installed_distributions, get_prog
File "/home/andrew/.local/lib/python3.5/site-packages/pip/utils/__init__.py", line 23, in <module>
from pip.locations import (
File "/home/andrew/.local/lib/python3.5/site-packages/pip/locations.py", line 10, in <module>
from distutils.command.install import install, SCHEME_KEYS # noqa
File "/usr/local/google-cloud-sdk/platform/google_appengine/lib/distutils/distutils/command/install.py", line 258
raise DistutilsOptionError, \
^
SyntaxError: invalid syntax
The file usr/local/google-cloud-sdk/platform/google_appengine/lib/distutils/distutils/command/install.py has lines like this and is compatible with python 2.1. Note. this is not the official google repository but it's accurate:
print "config vars:"
This means that install.py is a python 2 file and you are running pip from python 3. There probably is some incompatibility between them.

Resources