Multiple packages cannot install on PyCharm - python

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?

Related

No module named 'OpenSSL' in python

I search on google how to add OpenSSL in python. The command is easy to run.
pip install pyOpenSSL or pip3 install pyOpenSSL. I don't know if my OpenSSL is already installed. I have this response when I installed openssl.
DEPRECATION: Configuring installation scheme with distutils config files is deprecated and will no longer work in the near future. If you are using a Homebrew or Linuxbrew Python, please see discussion at https://github.com/Homebrew/homebrew-core/issues/76621
Requirement already satisfied: pyopenssl in /usr/local/lib/python3.9/site-packages (20.0.1)
Requirement already satisfied: cryptography>=3.2 in /usr/local/lib/python3.9/site-packages (from pyopenssl) (36.0.1)
Requirement already satisfied: six>=1.5.2 in /usr/local/lib/python3.9/site-packages (from pyopenssl) (1.16.0)
Requirement already satisfied: cffi>=1.12 in /usr/local/lib/python3.9/site-packages (from cryptography>=3.2->pyopenssl) (1.15.0)
Requirement already satisfied: pycparser in /usr/local/lib/python3.9/site-packages (from cffi>=1.12->cryptography>=3.2->pyopenssl) (2.21)
DEPRECATION: Configuring installation scheme with distutils config files is deprecated and will no longer work in the near future. If you are using a Homebrew or Linuxbrew Python, please see discussion at https://github.com/Homebrew/homebrew-core/issues/76621
this is my index.py code
import base64
import json
import requests
from OpenSSL import crypto
when I run this command python3 index.py. I always get this error
ModuleNotFoundError: No module named 'OpenSSL'
May i know what's the issue in my setup? Im new in python code. My python version is 3.10.0
It looks like you have pyopenssl installed for a Python 3.9 installation (look at the path: /usr/local/lib/python3.9), but you are trying to run with a Python 3.10 installation.
Use the pip from your Python 3.10 installation to install the required packages. python3 -m pip install pyOpenSSL should do that, regardless of what the standalone pip command resolves to.

Issue with impacket & 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

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

PEP3101 checker installation

I want to check PEP-3101 standard for some codes that I have, for this, I want to install flake8-pep3101.
I can not directly install it as it requires PIP upgrade, so I upgrade my PIP from 19.0.3 to 19.1.1.
After upgrade, I began to install it by running
pip install flake8-pep3101
I received this error:
"Collecting flake8-pep3101pip ERROR: Could not find a version that satisfies the requirement flake8-pep3101pip (from versions: none)
ERROR: No matching distribution found for flake8-pep3101pip"
I already have FLAKE8 installed and Phyton 3.7.
What can I do to solve this problem ? it seems that there is no flake8-pep3101 module for this particular python.
I tried to upgrade FLAKE8 using PIP command "pip install --upgrade FLAKE8" and "pip3 install --upgrade FLAKE8":
It gives me error :
Requirement already up-to-date: FLAKE8 in c:\users\mydir\dev\myvirt\lib\site-packages (3.7.7) Requirement already satisfied, skipping upgrade: entrypoints<0.4.0,>=0.3.0 in c:\users\mydir\dev\myvirt\lib\site-packages (from FLAKE8) (0.3) Requirement already satisfied, skipping upgrade: pycodestyle<2.6.0,>=2.5.0 in c:\users\mydir\dev\myvirt\lib\site-packages (from FLAKE8) (2.5.0)
Requirement already satisfied, skipping upgrade: pyflakes<2.2.0,>=2.1.0 in c:\users\mydir\dev\myvirt\lib\site-packages (from FLAKE8) (2.1.1) Requirement already satisfied, skipping upgrade: mccabe<0.7.0,>=0.6.0 in c:\users\mydir\dev\myvirt\lib\site-packages (from FLAKE8) (0.6.1)
From what I can tell, you need to update/reinstall FLAKE8.
To update FLAKE8, use:
pip install --upgrade `FLAKE8`
To install the latest version of FLAKE8, use:
pip install `FLAKE8`
To install a specific version of FLAKE8, use:
pip install FLAKE8==<VERSION>
To install a version of FLAKE8 greater than or equal to one version and less than another, use:
pip install FLAKE8>=<LOW>,<HIGH>
NOTE: if you're using python3 use pip3 instead of pip.
Good luck.

pipenv install django==2.1 not working on google collab

I have already installed pipenv using,
pip install pipenv on the directory which was installed successfully. But
pipenv install Django==2.1 does not seem to work. In fact, no command is getting executed using pipenv.
pip install pipenv
Collecting pipenv
Downloading https://files.pythonhosted.org/packages/13/b4/3ffa55f77161cff9a5220f162670f7c5eb00df52e00939e203f601b0f579/pipenv-2018.11.26-py3-none-any.whl (5.2MB)
100% |████████████████████████████████| 5.2MB 5.5MB/s
Requirement already satisfied: setuptools>=36.2.1 in /usr/local/lib/python3.6/dist-packages (from pipenv) (40.9.0)
Collecting virtualenv-clone>=0.2.5 (from pipenv)
Downloading https://files.pythonhosted.org/packages/ba/f8/50c2b7dbc99e05fce5e5b9d9a31f37c988c99acd4e8dedd720b7b8d4011d/virtualenv_clone-0.5.3-py2.py3-none-any.whl
Requirement already satisfied: certifi in /usr/local/lib/python3.6/dist-packages (from pipenv) (2019.3.9)
Requirement already satisfied: pip>=9.0.1 in /usr/local/lib/python3.6/dist-packages (from pipenv) (19.0.3)
Collecting virtualenv (from pipenv)
Downloading https://files.pythonhosted.org/packages/33/5d/314c760d4204f64e4a968275182b7751bd5c3249094757b39ba987dcfb5a/virtualenv-16.4.3-py2.py3-none-any.whl (2.0MB)
100% |████████████████████████████████| 2.0MB 17.1MB/s
Installing collected packages: virtualenv-clone, virtualenv, pipenv
Successfully installed pipenv-2018.11.26 virtualenv-16.4.3 virtualenv-clone-0.5.3
pipenv install Django==2.1
File "", line 1
pipenv install Django==2.1
^
SyntaxError: invalid syntax
*
Anything on Google Colab suggestions would be very helpful!
*
pip is a shell command. I assume Google Colab has made pip available as a special command(*) (without the % syntax), but that doesn't mean any other shell command works as such. That is why you get a SyntaxError: it is not recognised as normal Python syntax.
You can work around it by using !pipenv install 'Django==2.1' (the single quotes may not be necessary, but the exclamation work is).
I doubt, however, that you really need a virtual environment in the first place. This is not on your regular machine, where you may want to keep dependencies apart. Instead, just start a new notebook for a new project, and install Django as normal: pip install Django. I wouldn't bother with pipenv and virtual environments inside notebooks. There doesn't seem to be any use for it.
(*) Try, for example, pip?, and note the help lists its usage with the %pip syntax. I assume that, if it's not ambiguous, Colab will use %pip when called as pip. The same works for, for example, ls instead of %ls.

Categories