ModuleNotFoundError during pip install when module is actually installed - python

I tried installing a python package (BentoML) using pip install bentoml, and I received the following error, which gives a ModuleNotFoundError: No module named 'wrapt'. However, the wrapt module is actually included in my site-packages folder, so a pip install wrapt results in the message that I already have wrapt installed.
I can install other packages using pip, but the alembic package causes this issue. I was able to install using pip using my Anaconda Python, but I want it installed with this Python version. What is the best way forward?
I'm using Python 3.8.1 on a Windows 10 device.
ERROR: Command errored out with exit status 1:
command: 'c:\users\username\appdata\local\programs\python\python38\python.exe' 'c:\users\username\appdata\local\programs\python\python38\lib\site-packages\pip\_vendor\pep517\_in_process.py' get_requires_for_build_wheel 'C:\Users\user~1.lastname\AppData\Local\Temp\tmpd30adik_'
cwd: C:\Users\username\AppData\Local\Temp\pip-install-qers2adl\alembic
Complete output (14 lines):
Fatal Python error: init_import_size: Failed to import the site module
Python runtime state: initialized
Traceback (most recent call last):
File "c:\users\username\appdata\local\programs\python\python38\lib\site.py", line 580, in <module>
main()
File "c:\users\username\appdata\local\programs\python\python38\lib\site.py", line 573, in main
execsitecustomize()
File "c:\users\username\appdata\local\programs\python\python38\lib\site-packages\certifi_win32\bootstrap.py", line 37, in _execsitecustomize
_register_bootstrap_functions()
File "c:\users\username\appdata\local\programs\python\python38\lib\site-packages\certifi_win32\bootstrap.py", line 25, in _register_bootstrap_functions
from . import wrapt_certifi
File "c:\users\username\appdata\local\programs\python\python38\lib\site-packages\certifi_win32\wrapt_certifi.py", line 3, in <module>
import wrapt
ModuleNotFoundError: No module named 'wrapt'
----------------------------------------
ERROR: Command errored out with exit status 1: 'c:\users\username\appdata\local\programs\python\python38\python.exe' 'c:\users\username\appdata\local\programs\python\python38\lib\site-packages\pip\_vendor\pep517\_in_process.py' get_requires_for_build_wheel 'C:\Users\user~1.lastname\AppData\Local\Temp\tmpd30adik_' Check the logs for full command output.

Install using another version of Python. Open up an Anaconda prompt (or another version of Python on the same device), and run:
pip install alembic --target="c:\users\username\appdata\local\programs\python\python38\lib\site-packages"
This was the same approach I used when I broke Python after trying to uninstall/reinstall wrapt. The other Python version installs alembic to the correct location and the original install works.

Related

No module named 'MySQLdb' after installing mysqlclient

I am using PyCharm and I'm trying to make a simple script that connects to a database.
In the PyCharm terminal, both mysqlclient installations from here seem to fail.
(venv) C:\Users\erics\CS261>pip install mysqlclient-1.4.6-cp38-cp38-win_amd64.whl
mysqlclient-1.4.6-cp38-cp38-win_amd64.whl is not a supported wheel on this platform.
(venv) C:\Users\erics\CS261>pip install mysqlclient-1.4.6-cp38-cp38-win32.whl
mysqlclient-1.4.6-cp38-cp38-win32.whl is not a supported wheel on this platform.
In Windows's terminal, they are succesfully installed:
C:\Users\erics>pip install mysqlclient-1.4.6-cp38-cp38-win32.whl
Processing c:\users\erics\mysqlclient-1.4.6-cp38-cp38-win32.whl
Installing collected packages: mysqlclient
Successfully installed mysqlclient-1.4.6
Even though it is "succesfully installed", my script does not seem to run...
C:\Users\erics\CS261\venv\Scripts\python.exe C:/Users/erics/CS261/venv/Scripts/test.py
Traceback (most recent call last):
File "C:/Users/erics/CS261/venv/Scripts/test.py", line 1, in <module>
import MySQLdb
ModuleNotFoundError: No module named 'MySQLdb'
Process finished with exit code 1

Issue importing psycopg2 after installing from local archives (in order to specify pg_config path in setup.cfg)

I am trying to install and use psycopg2, using Python on Mac OS. After running into issue with install due to "pg_config not found" error, I downloaded source files and specified pg_config path in setup.cfg. Installation was successful but now psycopg2 encounters an error when imported.
Install
pip install /Users/k/Downloads/psycopg2-2.8.3
Processing ./Downloads/psycopg2-2.8.3
Installing collected packages: psycopg2
Running setup.py install for psycopg2: started
Running setup.py install for psycopg2: finished with status 'done'
Successfully installed psycopg2-2.8.3
Import error
import psycopg2
Traceback (most recent call last):
File "<console>", line 1, in <module>
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/psycopg2/__init__.py", line 50, in <module>
from psycopg2._psycopg import ( # noqa
ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/psycopg2/_psycopg.cpython-37m-darwin.so, 2): Library not loaded: libssl.1.1.dylib
Referenced from: /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/psycopg2/_psycopg.cpython-37m-darwin.so
Reason: image not found
Any help would be greatly appreciated!
If me, I would rather do it as follows:
$ pip install pipenv --user
$ pipenv shell
$ pipenv install psycopg2==2.8.3
$ python
>>> import psycopg2

ImportError: No module named build_lib

I'm trying to run the pip install command in this way: pip install pyverdict --upgrade, but I get the following error: ImportError: No module named build_lib. How can I resolve this?
More detailed error:
DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 won't be maintained after that date. A future version of pip will drop support for Python 2.7.
Collecting pyverdict
Using cached https://files.pythonhosted.org/packages/81/be/c7f5803f599fa74b26ac9b2be385f19f14ce573540371f1f2c1c59a51a80/pyverdict-0.1.3.1.tar.gz
ERROR: Complete output from command python setup.py egg_info:
ERROR: Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/pip-install-hBPHyv/pyverdict/setup.py", line 21, in <module>
from build_lib import build_and_copy
ImportError: No module named build_lib
----------------------------------------
ERROR: Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-install-hBPHyv/pyverdict/

gramex install error: import pip.req ImportError: No module named req

My Environment details:
Python 3.6.4 :: Anaconda, Inc.
anaconda-script.py Command line client (version 1.4.0)
pip 10.0.1
I'm getting below error while trying to install with
pip install -verbose gramex or
pip install -e . (from )
```
(gramex_34) <src_path>\\gramex>pip install -e .
Obtaining file:///<src_path>/gramex
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "<src_path>\gramex\setup.py", line 7, in
<module>
from pip.req import parse_requirements
ImportError: No module named req
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in <src_path>\gramex\
I could get the below ref on SoF its a usage issue with latest version of pip:
pip-git-issue
similar-issue-thread
UPDATE: Since Jun 2018, this issue does not arise.
ORIGINAL ANSWER:
Yes Joshua - this was raised as an issue but isn't fixed yet.
The workaround is to downgrade from pip 10 to pip 9 -- and then install. This is not ideal. Will try and have a fix soon.

how to install notify2 module in python 3.5 with my MAC computer?

tried the following command in the terminal,
$ pip3 install notify2
Collecting notify2
Using cached notify2-0.3.tar.gz
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/private/var/folders/fr/hgx7qkc14dsglj7724_9m5780000gn/T/pip-build-0aoqwq0g/notify2/setup.py", line 2, in <module>
import notify2
File "/private/var/folders/fr/hgx7qkc14dsglj7724_9m5780000gn/T/pip-build-0aoqwq0g/notify2/notify2.py", line 38, in <module>
import dbus
ImportError: No module named 'dbus'
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /private/var/folders/fr/hgx7qkc14dsglj7724_9m5780000gn/T/pip-build-0aoqwq0g/notify2/
So, it seems like I need to install dbus module first. So, I tried
$ pip3 install dbus
Collecting dbus
Could not find a version that satisfies the requirement dbus (from versions: )
No matching distribution found for bus
tried which pip
$ which pip
/Library/Frameworks/Python.framework/Versions/3.5/bin/pip
And does anyone know what shall I do?
You need to install dbus using brew install dbus and then pip install dbus-python

Categories