Issue with impacket & python - python

Hi there boys and girls,
I am trying to run a script written in python and the console is telling me this:
Install the following library to make this script work
Impacket : https://github.com/CoreSecurity/impacket.git
PyCrypto : https://pypi.python.org/pypi/pycrypto
The problem is that I have already installed those python packages in python3 so when I make a request via pip for those packages I receive this:
Requirement already satisfied: impacket in /usr/local/lib/python3.8/dist-packages (0.9.17)
Requirement already satisfied: ldap3>=2.5.0 in /usr/lib/python3/dist-packages (from impacket) (2.7)
Requirement already satisfied: six in /usr/lib/python3/dist-packages (from impacket) (1.15.0)
Hid the rest of the lines but the idea is that. I understand that the package is already installed in my system but I cannot use those with python2.7.
Any idea how to solve this?

In this case the error is because you have not installed impacket for python2.7.
Before installing impacket we need to install pip2 in python2.7, Download get-pip.py form Link
if pip2 is already installed you can verify this by
pip --verison, output of that command should be
pip 20.3.3 from /usr/local/lib/python2.7/dist-packages/pip (python 2.7)
If pip2 is not installed then install pip2 in python2 package using sudo python2 get-pip.py
Next, install impacket for python2 using pip install . (this must be with in the impacket directory link)
then try to run your script

Related

Multiple packages cannot install on PyCharm

I am trying to use PyCharm for my python 3 coding on my Linux, and it works great 90% of the time, but I notice that on occasion I cannot import certain packages. For example, when I click Settings->Project->Python Interpreter and try to install 'opencv-python', I get this error:
AttributeError: module 'setuptools.build_meta' has no attribute '__legacy__'
When I try to install opencv-python with pip I get this message:
$ pip install opencv-python
Defaulting to user installation because normal site-packages is not writeable
Requirement already satisfied: opencv-python in ./.local/lib/python3.6/site-packages (4.5.1.48)
Requirement already satisfied: numpy>=1.13.3 in ./.local/lib/python3.6/site-packages (from opencv-python) (1.19.2)
There seems to be some discrepency between the packages my computer has installed and the packages that PyCharm has installed. How can I solve this problem?

Python no module named 'requests' even install requests

I run my python scrapy project shows the error no module named 'requests'
So I type pip install requests
and then terminal information:
Requirement already satisfied: requests in ./Library/Python/2.7/lib/python/site-packages (2.22.0)
Requirement already satisfied: chardet<3.1.0,>=3.0.2 in ./Library/Python/2.7/lib/python/site-packages (from requests) (3.0.4)
Requirement already satisfied: idna<2.9,>=2.5 in ./Library/Python/2.7/lib/python/site-packages (from requests) (2.8)
Requirement already satisfied: urllib3!=1.25.0,!=1.25.1,<1.26,>=1.21.1 in ./Library/Python/2.7/lib/python/site-packages (from requests) (1.25.7)
Requirement already satisfied: certifi>=2017.4.17 in ./Library/Python/2.7/lib/python/site-packages (from requests) (2019.11.28)
type command pip list can see request 2.22.0
I type command python --version to check the python version:
python 2.7.16
Finally I run my scrapy project again still see the same error no module named 'requests'
I have no idea how to fix the error now, any help would be appreciated. Thanks.
Install python3 and pip3 and then pip3 install requests
if you are on ubuntu python3 is installed by default
you should first install pip3 by apt install python3-pip and then pip3 install requests
If you are using two different versions of Python, it should explain why you can't use your module.
To install the module on Python 3, try:
pip3 install requests
And make sure, you are using the correct version.
Check if you are using the same interpreter to which you have installed the package using pip install. As a best practice to avoid this type of issues when you have multiple versions of python, use pip as a module instead of directly calling pip.
eg:
python -m pip install requests
python3 -m pip install requests

I have pip version 19.3.1 but when installing requirements, it says I have version 9.0.3

I'm trying to install requirements.txt in pycharm, but pip version indicated version 9.0.3 whereas I have 19.3.1. It will not update saying that requirement is already satisfied.
I've tried upgrading it but it says requirement already satisfied
You are using pip version 9.0.3, however version 19.3.1 is available.
You should consider upgrading via the 'python -m pip install --upgrade pip' command.
:\Users\User\Documents\Learn\Python\photography>python -m pip install --upgrade pip
Requirement already up-to-date: pip in c:\users\user\documents\learn\python\photography\venv\lib\site-packages (19.3.1)
Do you have two versions of Python installed? That could be the cause.
Your terminal has photography\venv activated
I'm guessing Pycharm is not using that virtualenv
Regardless, the version of pip shouldn't stop you from using a requirements file

pip install error - ImportError: No module named finsymbols

When I run:
sudo -H pip install finsymbols
I get the below response:
Requirement already satisfied: finsymbols in /usr/local/lib/python2.7/dist-packages
Requirement already satisfied: beautifulsoup4>=4.2.1 in /usr/local/lib/python2.7/dist-packages (from finsymbols)
then when I run
$ python
>>> from finsymbols import symbols
I get
File "", line 1, in
ImportError: No module named finsymbols
My question is, why am I getting the error when the module is installed?
You may have multiple versions of Python.
Requirement already satisfied: finsymbols in /usr/local/lib/python2.7/dist-packages Requirement already satisfied: beautifulsoup4>=4.2.1 in /usr/local/lib/python2.7/dist-packages (from finsymbols)
Pip has installed it in python2.7 path. Your default Python may be different.
So try using
$ python2.7
instead of
$ python
If you want to install a module that runs on Python 3.x, you need to use
pip3 install module_name
Or link the pip3 executable in /usr/bin to replace pip. In this way, you can use pip to install Python 3.x modules.
Here I strongly recommend to use virtualenv to manage your Python module environments. More details can be found here.
Thanks jonatan, that worked.
I ran
pip install finsymbols
not
sudo -H pip install finsymbols
and that fixed the issue

Python packages hash not matching whilst installing using pip

I am using pip to install all my python packages but get error as shown in the trace below. What is the problem and how can I solve it?
usr#comp:~$ pip install flask
Collecting flask
Using cached Flask-0.11.1-py2.py3-none-any.whl
Collecting itsdangerous>=0.21 (from flask)
Using cached itsdangerous-0.24.tar.gz
Collecting click>=2.0 (from flask)
Using cached click-6.6.tar.gz
Collecting Werkzeug>=0.7 (from flask)
Using cached Werkzeug-0.11.11-py2.py3-none-any.whl
Requirement already satisfied (use --upgrade to upgrade): Jinja2>=2.4 in /usr/lib/python2.7/dist-packages (from flask)
Requirement already satisfied (use --upgrade to upgrade): MarkupSafe in /usr/lib/python2.7/dist-packages (from Jinja2>=2.4->flask)
THESE PACKAGES DO NOT MATCH THE HASHES FROM THE REQUIREMENTS FILE. If you have updated the package versions, please update the hashes. Otherwise, examine the package contents carefully; someone may have tampered with them.
Werkzeug>=0.7 from https://pypi.python.org/packages/a9/5e/41f791a3f380ec50f2c4c3ef1399d9ffce6b4fe9a7f305222f014cf4fe83/Werkzeug-0.11.11-py2.py3-none-any.whl#md5=c63a21eedce9504d223ed89358c4bdc9 (from flask):
Expected md5 c63a21eedce9504d223ed89358c4bdc9
Got 13a168aafcc43354b6c79ef44bb0dc71
There is a similar problem (Why does pip fail with bad md5 hash for package?) from 2013 the solution that I tried that worked for me is this:
sudo pip install --no-cache-dir flask
given by attolee
The problem here is the Python package was updated with new hash value while pip was trying to install the Python package using the old hash value cached in pip cache directory. This cache needs to be purge before the pip install attempt. So the full solution is:
python -m pip cache purge
python -m pip install <package>
--no-cache-dir did not work for me in raspberry pi 4 at first.
Found that the problem was due to unexpected network change/failure during pip installation
I had to download the broken .whl file manually with wget
and install it like below:
sudo pip install scipy-1.3.0-cp37-cp37m-linux_armv7l.whl
followed by
sudo pip install --no-cache-dir keras
Then it worked.
Looks like a cache problem, the cached package is different from REQUIREMENTS.
Perhaps caused by last updates interruption.
I did this which fixed my problem:
rm ~/.cache/pip -rf
You need to upgrade your pip into the newer version:
Using this command:
python -m pip install -upgrade pip
for Mac/Linux operating system and use
python -m pip install --upgrade tensorflow
for Windows to update your pip. Then run your command
pip install flask
In case you got this error while using pipenv try
$ pipenv --clear
$ pipenv lock
$ pipenv install
first, try to upgrade your pip then install the library
python -m pip install -upgrade pip
if it didn't work just try to install it without the cash
pip install --no-cache-dir the_library_name
I got the error during installing panads
You need to remove the cache and reinstall .
pip install --no-cache-dir flask
I had a similar issue for a different module. It was caused by network failure. My fix was nothing complex but another attempt at installing it and it worked.
maybe pipiserver(where you pip install from) upload a pkg for example flask-1.0.0.tar.gz, and rm is upload a new flask-1.0.0.tag.gz,if new pkg code has changed ,the hash must be different,there is two ways:
installl an older pkg version =, pip install flask==0.0.9
wait new pkg release flask==1.0.1 or cache expiration.
I have tried to clear pip cache with "-m pip cache purge" and using the "--no-cache-dir" argument but it was not helping.
In my case it was VPN being active during the attempts to install the package. As soon as I have turned it off everything worked as expected.

Categories