Python can not import pywifi - python

I have install pywifi module and it success, when I try to import pywifi,I got this error.
>>> import pywifi
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Library/Python/2.7/site-packages/pywifi/__init__.py", line 15, in <module>
from .wifi import PyWiFi
File "/Library/Python/2.7/site-packages/pywifi/wifi.py", line 15, in <module>
from .iface import Interface
File "/Library/Python/2.7/site-packages/pywifi/iface.py", line 15, in <module>
raise NotImplementedError
NotImplementedError
someone can help me?

Which python version are you running? It might be because it is installed as a Python 3 package and you're running Python 2.7 or the opposite.
To specifically install the package for Python 3, try entering this command:
pip3 install pywifi
or
python3 -m pip install pywifi
To specifically install the package for Python 2, try entering this command:
pip2 install pywifi
or
python -m pip install pywifi

I got similar errors, from the error message, I tried to install those packages that pywifi seemed to depend on, i.e., I ran
pip install comtypes
pip install iface
then it worked.

Related

Can't import Image from PIL because of this error

When I import Image from PIL I get this error message.
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/pi/.local/lib/python3.8/site-packages/PIL/Image.py", line 94, in <module>
from . import _imaging as core
ImportError: cannot import name '_imaging' from 'PIL' (/home/pi/.local/lib/python3.8/site-packages/PIL/__init__.py)
The way it says to install pillow errors out for me
pip install --upgrade Pillow
It says that it doesn't have the .whl so it defaults to the old setup.py then errors and doesn't install.
only
sudo apt install python3-pil
seems to install pillow correctly
this is for python3.8.x
Try using pip3 instead of pip. pip sometimes defaults to Python 2.x. See the following question to change this behavior: How to override the pip command to Python3.x instead of Python2.7?
pip3 install --upgrade Pillow

how to make pip works again?

I tried to make pip3 as the main pip in my Linux by writing this code
alias pip=pip3
and after that what ever command I give to pip, it keeps on giving the same error message:
Traceback (most recent call last):
File "/usr/bin/pip3", line 9, in <module>
from pip import main
ImportError: cannot import name 'main'
For linux, you can use the argument -m of python bin.
python3 -m pip
so, you can use this allias
alias pip="python3 -m pip"
Use python3 -m pip install --user packagename

Troubles installing mysqlclient with pip3

I'm trying to set up a python 3.6 environment with Django. The installation instructions say I should install mysqlclient to be able to connect to mySQL. I get this:
dennis#django:~$ sudo -H pip3 install mysqlclient
Collecting mysqlclient
Using cached mysqlclient-1.3.10.tar.gz
Complete output from command python setup.py egg_info:
/bin/sh: 1: mysql_config: not found
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/pip-build-4jiw3hvk/mysqlclient/setup.py", line 17, in <module>
metadata, options = get_config()
File "/tmp/pip-build-4jiw3hvk/mysqlclient/setup_posix.py", line 44, in get_config
libs = mysql_config("libs_r")
File "/tmp/pip-build-4jiw3hvk/mysqlclient/setup_posix.py", line 26, in mysql_config
raise EnvironmentError("%s not found" % (mysql_config.path,))
OSError: mysql_config not found
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-4jiw3hvk/mysqlclient/
You are using pip version 8.1.1, however version 9.0.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
mySQL is properly installed. What should be in the mysql_config file?
When I try to upgrade pip3 I get this:
dennis#django:~$ sudo -H pip3 install --upgrade pip3
Collecting pip3
Could not find a version that satisfies the requirement pip3 (from versions: )
No matching distribution found for pip3
You are using pip version 8.1.1, however version 9.0.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
After installing mysqlclient with pip3, I noticed that the module was installed in the python3.5 directory instead of in the python3.6 directory so when I tried to import the MySQLdb module running python3.6, it was not found
dennis#django:~/python_db$ python
Python 3.6.0+ (default, Feb 4 2017, 11:11:46)
[GCC 5.4.1 20161202] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import MySQLdb
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'MySQLdb'
Error in sys.excepthook:
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/apport_python_hook.py", line 63, in apport_excepthook
from apport.fileutils import likely_packaged, get_recent_crashes
File "/usr/lib/python3/dist-packages/apport/__init__.py", line 5, in <module>
from apport.report import Report
File "/usr/lib/python3/dist-packages/apport/report.py", line 30, in <module>
import apport.fileutils
File "/usr/lib/python3/dist-packages/apport/fileutils.py", line 23, in <module>
from apport.packaging_impl import impl as packaging
File "/usr/lib/python3/dist-packages/apport/packaging_impl.py", line 23, in <module>
import apt
File "/usr/lib/python3/dist-packages/apt/__init__.py", line 23, in <module>
import apt_pkg
ModuleNotFoundError: No module named 'apt_pkg'
Original exception was:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'MySQLdb'
>>>
I then reran using python 3.5 and it was found. How do I install modules using pip3 into the 3.6 directory?
If you're using Mac OS, try this:
brew install mysql
If you're using Ubuntu14/16, try this:
sudo apt install libmysqlclient-dev
and one more:
pip3 can be updated with sudo pip3 install -U pip
LDFLAGS=-L/usr/local/opt/openssl/lib pip install mysqlclient
In my case the issue was solved by doing the following:
sudo aptitude install libmysqlclient-dev
As I was using Python 3.x, the following was also necessary:
sudo aptitude install python3-dev
If you're running MAMP on OSX, do this:
export PATH=$PATH:/Applications/MAMP/Library/bin
In Debian Stretch the required package name seems to have changed to default-libmysqlclient-dev
https://packages.debian.org/stretch/default-libmysqlclient-dev
you can try this to install mysql to a particular python directory, for example w/ python 3.6
sudo python3.6 /usr/bin/pip3 install mysqlclient
Looking over this old question (while looking for something else), I observe that the problem could be that the directory containing mysql_config was not in the current $PATH. Apparently that's what the install script uses to try to find it. It's possible for "mysql to be installed," but not on the $PATH – or for the $PATH to refer to the wrong version.

pip3 install pyautogui fails with error code 1 Mac OS

I tried installing the autogui python extension:
pip3 install pyautogui
And this installation attempt results in the following error message:
Collecting pyautogui
Using cached PyAutoGUI-0.9.33.zip
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/private/var/folders/00/zcr6mkx90hg7kr4x_ks6nhhw0000gn/T/pip-build-edy15oyn/pyautogui/setup.py", line 6, in <module>
version=__import__('pyautogui').__version__,
File "/private/var/folders/00/zcr6mkx90hg7kr4x_ks6nhhw0000gn/T/pip-build-edy15oyn/pyautogui/pyautogui/__init__.py", line 110, in <module>
from . import _pyautogui_osx as platformModule
File "/private/var/folders/00/zcr6mkx90hg7kr4x_ks6nhhw0000gn/T/pip-build-edy15oyn/pyautogui/pyautogui/_pyautogui_osx.py", line 4, in <module>
import Quartz
File "/usr/local/lib/python3.5/site-packages/Quartz/__init__.py", line 5, in <module>
import objc
File "/usr/local/lib/python3.5/site-packages/objc/__init__.py", line 18, in <module>
_update()
File "/usr/local/lib/python3.5/site-packages/objc/__init__.py", line 15, in _update
import objc._objc as _objc
ImportError: dlopen(/usr/local/lib/python3.5/site-packages/objc/_objc.cpython-35m-darwin.so, 2): Symbol not found: _PyObject_REPR
Referenced from: /usr/local/lib/python3.5/site-packages/objc/_objc.cpython-35m-darwin.so
Expected in: flat namespace
in /usr/local/lib/python3.5/site-packages/objc/_objc.cpython-35m-darwin.so
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /private/var/folders/00/zcr6mkx90hg7kr4x_ks6nhhw0000gn/T/pip-build-edy15oyn/pyautogui
My Mac OS version is OS X El Capitan 10.11.3, my Python3 version is 3.5.1, and my pip3 version is pip 8.0.2.
There seems to be a similar question on Stackoverflow (Cannot install pip install pyautogui, error code 1), but the fix does not apply to my problem; I have already installed "pillow". Also, I have read the documentation (https://pypi.python.org/pypi/PyAutoGUI), and installed pyobjc-core as well as pyobjc. Setuptools are installed and up-to-date.
Does anyone have an idea how to fix this error (and install pyautogui)? I think the error might originate, because _PyObject_REPR is missing in Python 3.5.1.
I found a workaround. This code by "Kentzo" fixed the issue for me:
pip3 install https://github.com/GreatFruitOmsk/pyobjc-core/releases/download/v3.0.5.dev0/pyobjc-core-3.0.5.tar.gz
Since the code is not written by me, please use this workaround at your own risk.
If you are like me and had no success installing pyautogui, here is what I did to fix the issue:
Install Xcode from the Mac App Store. This is a requirement for installing PyObjC. Details can be found here.
sudo pip3 install pyobjc-core
sudo pip3 install pyobjc
sudo pip3 install Pillow
sudo pip3 install pyautogui
Steps 2, 3, and 5 are detailed here.
Step 4 is described here, another Stackoverflow post.
SOLVED
Run:
1. sudo pip3 install pil
2. sudo pip3 install Pillow
3. sudo pip3 install pyautogui
Bingo! installed without an error
The sequence of steps which worked for me on macOS High Sierra(10.13.4) :
Install Xcode from AppStore
activate virtual environment (if needed)
pip3 install pyobjc-core
pip3 install pyobjc-framework-Quartz
pip3 install image
pip3 install pyautogui

python3.4 pip ImportError: No Module named 'pkg_resources'

pip is not working in my python3.4
$ pip install django
Traceback (most recent call last):
File "usr/bin/pip", line 5, in <module>
from pkg_resources import load_entry_point
ImportError: No module named 'pkg_resources'
$ pip
Traceback (most recent call last):
File "usr/bin/pip", line 5, in <module>
from pkg_resources import load_entry_point
ImportError: No module named 'pkg_resources'
How do I fix this? What's the problem? Thanks
i just ran into the same error, here is what i've done to fix it:
sudo apt-get remove --purge python-pkg-resources
sudo apt-get install ubuntu-desktop
Try >sudo pip install django< I think that ought to do it
well then I suspect your pip is messed up so try
sudo apt-get install --reinstall python-pkg-resources
however if you are using Python 3 you may need to adjust to insure that you get the Python 3 environment set up rather than the P2 default
see here for more on that
How to use pip with Python 3.x alongside Python 2.x

Categories

Resources