ModuleNotFoundError: No module named 'cleverhans.utils_keras' in Colab - pip

I used the following to install cleverhans in Colab:
!pip install -qq -e git+http://github.com/tensorflow/cleverhans.git#egg=cleverhans
import sys
sys.path.append('/content/src/cleverhans')
import cleverhans
And it seems to work good. Then I use the following:
from cleverhans.utils_keras import KerasModelWrapper
wrap = KerasModelWrapper(network)
And I get:
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-42-bf6d85d04ab3> in <module>()
----> 1 from cleverhans.utils_keras import KerasModelWrapper
2 wrap = KerasModelWrapper(network)
ModuleNotFoundError: No module named 'cleverhans.utils_keras'

Module cleverhans.utils_keras is a part of cleverhans_v3.1.0. The subdirectory has its own setup.py, i.e. it's its own separate package. Install it with the command
!pip install -U "git+https://github.com/cleverhans-lab/cleverhans.git#egg=cleverhans&subdirectory=cleverhans_v3.1.0"

Related

ImportError: cannot import name 'just_fix_windows_console' from 'colorama'

I'm trying to execute bayesian optimizer but I always get the same error.
I tried "pip install -U colorama" but it still doesn't work
ImportError Traceback (most recent call last)
~\AppData\Local\Temp\ipykernel_13036\1140567575.py in <module>
----> 1 from colorama import just_fix_windows_console
2 just_fix_windows_console()
ImportError: cannot import name 'just_fix_windows_console' from 'colorama'
I had the same issue. For me, the following worked:
pip install colorama=0.4.4
pip install bayesian-optimization=1.4.0

'No module named 'pyfirmata'' error even though I have already installed pyfirmata using pip?

I started by uploading the StandardFirmata example from the Arduino IDE onto my Arduino UNO. I then successfully installed pyfirmata onto my windows pc using pip3 install pyfirmata to the path c:\users\ta319\anaconda3\lib\site-packages, however, when I try to run the following code in spyder:
#!/usr/bin/env python3
import pyfirmata
import time
if __name__ == '__main__':
board = pyfirmata.Arduino('COM4 (Arduino UNO)')
print("Communication Successfully started")
while True:
board.digital[13].write(1)
time.sleep(1)
board.digital[13].write(0)
time.sleep(1)
I get this error:
Traceback (most recent call last):
File
"C:\Users\ta319\AppData\Local\Programs\Spyder\pkgs\spyder_kernels\py3compat.py",
line 356, in compat_exec
exec(code, globals, locals)
File "c:\users\ta319\firmata setup.py", line 3, in
import pyfirmata
ModuleNotFoundError: No module named 'pyfirmata'
Any suggestions would be greatly appreciated, thanks!
You probably installed with pip and not pip3, try
python3 -m pip install pyfirmata or pip3 install pyfirmata

how to solve Module not found error? ( installed the module and error persists)

I have installed the module tradingeconomics on cmd and when i try to import the library it throws this error , how to solve it ?
'
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-7-15897cf55e0a> in <module>
1 #Importing required libraries
----> 2 import tradingeconomics as te
3 import pandas as pd
4 import numpy as np
5 from datetime import datetime,date,timedelta
ModuleNotFoundError: No module named 'tradingeconomics'
It is possible that you installed the module in an environment and you are not working in the environment, or you are working in an environment but the module was installed outside of the environment. I use a conda environment, you can set up one by typing this in the terminal
conda create --new myenv
conda activate myenv
set up pip using the following
conda install -n myenv pip
then you can download modules
pip install tradingeconomics
use conda deactivate to exit the environment,
you can learn more about conda here https://docs.conda.io/projects/conda/en/latest/user-guide/tasks/manage-environments.html#using-pip-in-an-environment

Making a discord bot in python

Hello there I'm currently making a discord bot in python and i get these errors : Click to see photo
import coloredlogs, logging
import discord
from discord.ext import commands
from motor.motor_asyncio import AsyncIOMotorClient
Here is the error when i run python bot.py :
Traceback (most recent call last):
File "C:\Users\%user%\Desktop\Omicron-Entetie\bot.py", line 4, in <module>
import coloredlogs, logging
File "C:\Users\%user%\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\coloredlogs\__init__.py", line 212, in <module>
from humanfriendly.compat import coerce_string, is_string, on_windows
ImportError: cannot import name 'on_windows' from 'humanfriendly.compat' (C:\Users\%user%\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\humanfriendly\compat.py)
I suggest you try to check if the add-ons are actually installed. Open the command prompt and type "pip install (addon)"
If that doesn't work and the command prompt gives you an error try with: py -m pip install (whatever you need to install).
If that doesn't work either, make sure you have imported all of the add-ons.

Version upgrade to scikit-learn

I wanted to do LDA on some data and so followed this example:
http://scikit-learn.org/stable/auto_examples/decomposition/plot_pca_vs_lda.html#example-decomposition-plot-pca-vs-lda-py
however, on trying:
from sklearn.discriminant_analysis import LinearDiscriminantAnalysis
I got an import error. Huh, maybe this is a new function, I thought. So I updated scikit-learn via conda from 0.15.2 to 0.17. But now I can't even import sklearn:
import sklearn
RuntimeError: module compiled against API version a but this version of numpy is 9
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "//anaconda/lib/python2.7/site-packages/sklearn/__init__.py", line 57, in <module>
from .base import clone
File "//anaconda/lib/python2.7/site-packages/sklearn/base.py", line 9, in <module>
from scipy import sparse
File "//anaconda/lib/python2.7/site-packages/scipy/sparse/__init__.py", line 213, in <module>
from .csr import *
File "//anaconda/lib/python2.7/site-packages/scipy/sparse/csr.py", line 13, in <module>
from ._sparsetools import csr_tocsc, csr_tobsr, csr_count_blocks, \
ImportError: numpy.core.multiarray failed to import
I tried updating numpy and scipy using both pip and conda to no avail. I then tried a complete clean re-install of anaconda by:
rm -rf ~/anaconda
and a subsequent download of the .pkg from http://docs.continuum.io/anaconda/install#anaconda-install
Still I get the same error. Here are my OS and package details:
Mac OSX 10.5.2
bash-3.2$ conda -V
conda 3.18.6
scipy==0.16.0
numpy==1.9.1
scikit-learn==0.17
The last of these via pip freeze since I can't import it. I'm going nuts here. Any help much appreciated.
Try:
conda install numpy=1.10.1
I've had that module compiled against API version a but this version of numpy is 9 error before, and this solved it for me.

Resources