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.
Related
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
Good morning!
Until yesterday I was using python 2.7 and using the following code for writing output files for my scripts:
import sys
reload(sys)
sys.setdefaultencoding('utf-8')
But now I'm upgrading my code to python 3.7, so now I need to use importlib.reloadinstead of just reload. However, typing sudo -H pip3 install importlib on my shell gives me the following error:
Collecting importlib
Using cached https://files.pythonhosted.org/packages/31/77/3781f65cafe55480b56914def99022a5d2965a4bb269655c89ef2f1de3cd/importlib-1.0.4.zip
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/usr/local/lib/python3.7/site-packages/setuptools/__init__.py", line 6, in <module>
import distutils.core
File "/usr/local/Cellar/python/3.7.2_2/Frameworks/Python.framework/Versions/3.7/lib/python3.7/distutils/core.py", line 16, in <module>
from distutils.dist import Distribution
File "/usr/local/Cellar/python/3.7.2_2/Frameworks/Python.framework/Versions/3.7/lib/python3.7/distutils/dist.py", line 19, in <module>
from distutils.util import check_environ, strtobool, rfc822_escape
File "/usr/local/Cellar/python/3.7.2_2/Frameworks/Python.framework/Versions/3.7/lib/python3.7/distutils/util.py", line 9, in <module>
import importlib.util
ModuleNotFoundError: No module named 'importlib.util'
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /private/tmp/pip-install-3cz_3d6n/importlib/
After looking for solutions I also tried to upgrade setuptools, but that didn't fix my problem.
Many thanks in advance!
importlib at PyPI is an outdated package intended for very old Python versions. For new versions of Python importlib is a module from the standard library, you don't need to install it, it's always available.
My problem is as follows. I'm trying to package a python script a wrote to run on other computers with CX_freeze. After some fiddling I got the script packaged but when I went to run the code I got:
Miless-foobar-Pro:~ milesconn$ /Users/milesconn/\~/Documents/ IPgeolookupforXLSX ; exit;
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site- packages/cx_Freeze/initscripts/__startup__.py", line 14, in run
module.run()
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site- packages/cx_Freeze/initscripts/Console.py", line 26, in run
exec(code, m.__dict__)
File "/Users/milesconn/Desktop/IPgeolookupforXLSX.py", line 1, in <module>
import sys
ModuleNotFoundError: No module named 'pandas'
logout
[Process completed]
Now this was quite confusing because if I ran the script from IDLE everything worked perfectly. I started trying to run the original script (the .py not the .app) from terminal with simply python IP* but I continued to get the ModuleNotFoundError I upgraded Pandas w/ Pip3 and everything is up to date, still no luck. The program however worked perfectly when run in IDLE. I went on searching for my problem and found this link. I followed the advice and added to the top of my program
import sys
sys.path.insert(1,'/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages')
import pandas as pd
import numpy as np
Still the program ran from IDLE perfectly like before and now when I ran it in Terminal got this error
Traceback (most recent call last):
File "IPgeolookupforXLSX.py", line 4, in <module>
import pandas as pd
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pandas/__init__.py", line 19, in <module>
"Missing required dependencies {0}".format(missing_dependencies))
ImportError: Missing required dependencies ['numpy']
Now I don't know what to do from here. I believe if I get the program to run from terminal correctly then it'll hopefully couple with CX_Freeze and run. Thanks.
tl;dr: .py script runs from IDLE perfectly but when run from terminal it returns a ImportError: Missing required dependencies ['numpy']
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.
Installed Twilio successfully however when I attempt to import it in either the shell or terminal I get this error output:
Traceback (most recent call last):
File "<pyshell#1>", line 1, in <module>
import twilio
File "/Library/Python/2.7/site-packages/twilio/__init__.py", line 11, in <module>
from .rest.exceptions import TwilioRestException
File "/Library/Python/2.7/site-packages/twilio/rest/__init__.py", line 1, in <module>
from .base import set_twilio_proxy
File "/Library/Python/2.7/site-packages/twilio/rest/base.py", line 6, in <module>
from twilio.rest.resources import Connection
File "/Library/Python/2.7/site-packages/twilio/rest/resources/__init__.py", line 1, in <module>
from .util import (
File "/Library/Python/2.7/site-packages/twilio/rest/resources/util.py", line 5, in <module>
import pytz
ImportError: No module named pytz
Can anyone explain what is happening here? My version of Python is 2.7.9 and my pip installer is current as well. Output Error above is from importing in IDLE shell.
Twilio developer evangelist here.
The Twilio library requires pytz to be installed. Easiest way to get it installed is by running this on your terminal:
pip install pytz
Hope this helps