I'm trying to use the library pydub, but when I run the script i get this.
runfile('E:/OneDrive - usach.cl/chillbot/pydub.py', wdir='E:/OneDrive - usach.cl/chillbot')
Traceback (most recent call last):
File "<ipython-input-203-a38a65fe4502>", line 1, in <module>
runfile('E:/OneDrive - usach.cl/chillbot/pydub.py', wdir='E:/OneDrive - usach.cl/chillbot')
File "C:\ProgramData\Anaconda3\lib\site-packages\spyder\utils\site\sitecustomize.py", line 880, in runfile
execfile(filename, namespace)
File "C:\ProgramData\Anaconda3\lib\site-packages\spyder\utils\site\sitecustomize.py", line 102, in execfile
exec(compile(f.read(), filename, 'exec'), namespace)
File "E:/OneDrive - usach.cl/chillbot/pydub.py", line 9, in <module>
from pydub import AudioSegment
File "E:\OneDrive - usach.cl\chillbot\pydub.py", line 9, in <module>
from pydub import AudioSegment
ImportError: cannot import name 'AudioSegment'
I don't find information about the error, I'm using windows 10 with anaconda, the code that I'm running is.
from pydub import AudioSegment
AudioSegment.ffmpeg = "C:\ffmpeg\bin"
song = AudioSegment.from_mp3("I_eat_Plants_for_a_living-Unfaithful.mp3")
If I delete all the code except from pydub import AudioSegment I get the same error.
Having a file named pydub.py is a red flag. Try renaming it?
Related
I encounter this problem trying to open an excel file with the following code :
#===================================
#different import
import numpy as np
from matplotlib import pyplot as plt
import pandas as pd
section_copper = 50.11*8.04#[mm2]
section_alu = 50.18*5.07 #[mm2]
section_composite = 53.24*4.49 #[mm2]
section_steel = 50.35*10.23 #[mm2]
length = 400 #[mm]
data_steel = pd.read_excel(r"C:\Users\Alex\Downloads\MAPR2481-Lab1.xlsx",sheet_name=0)
data_aluminium = pd.read_excel(r"C:\Users\Alex\Downloads\MAPR2481-Lab1.xlsx",sheet_name=1)
data_copper = pd.read_excel(r"C:\Users\Alex\Downloads\MAPR2481-Lab1.xlsx",sheet_name=2)
data_composite = pd.read_excel(r"C:\Users\Alex\Downloads\MAPR2481-Lab1.xlsx",sheet_name=3)
The following message can be found in the console :
runfile('C:/Users/Alex/.spyder-py3/lab 1.py', wdir='C:/Users/Alex/.spyder-py3')
Traceback (most recent call last):
File "<ipython-input-16-9c6aa501dded>", line 1, in <module>
runfile('C:/Users/Alex/.spyder-py3/lab 1.py', wdir='C:/Users/Alex/.spyder-py3')
File "C:\Users\Alex\Anaconda3\lib\site-packages\spyder_kernels\customize\spydercustomize.py", line 827, in runfile
execfile(filename, namespace)
File "C:\Users\Alex\Anaconda3\lib\site-packages\spyder_kernels\customize\spydercustomize.py", line 110, in execfile
exec(compile(f.read(), filename, 'exec'), namespace)
File "C:/Users/Alex/.spyder-py3/lab 1.py", line 3, in <module>
import numpy as np
File "C:\Users\Alex\AppData\Roaming\Python\Python37\site-packages\numpy\__init__.py", line 143, in <module>
from . import _distributor_init
File "C:\Users\Alex\AppData\Roaming\Python\Python37\site-packages\numpy\_distributor_init.py", line 26, in <module>
WinDLL(os.path.abspath(filename))
File "C:\Users\Alex\Anaconda3\lib\ctypes\__init__.py", line 364, in __init__
self._handle = _dlopen(self._name, mode)
OSError: [WinError 193] %1 is not a valid Win32 application
I would be very grateful if someone could help me !
Please check this answer here
You are using Anaconda i assume.
You have installed the wrong version of python, like you have a 32bit system and u installed 64bit version of python.
Solution: re-install Anaconda as administrator (but first delete the first and all associated files with it).
hope this solves your issue.
My .py file looks like:
import hy
import example
foo2()
My .hy file looks like:
(defn foo2 [] (+ 1 1))
.hy file is in same folder as .py file.
If I run .py file I am getting error:
runfile('D:/del/hy2/untitled46.py', wdir='D:/del/hy2')
Reloaded modules: example
Traceback (most recent call last):
File "<ipython-input-274-3982ada2f243>", line 1, in <module>
runfile('D:/del/hy2/untitled46.py', wdir='D:/del/hy2')
File "C:\ProgramData\Anaconda3\lib\site-packages\spyder_kernels\customize\spydercustomize.py", line 827, in runfile
execfile(filename, namespace)
File "C:\ProgramData\Anaconda3\lib\site-packages\spyder_kernels\customize\spydercustomize.py", line 110, in execfile
exec(compile(f.read(), filename, 'exec'), namespace)
File "D:/del/hy2/untitled46.py", line 3, in <module>
foo2()
NameError: name 'foo2' is not defined
Question: How to correct my code above if I want to call function defined in .hy file from .py file with Python?
By the way this works fine.
In .py file:
import hy
import example
In .hy file:
(print "Hello, World")
Python can't resolve the name foo2 in that context. Maybe you meant from example import foo2? I'm assuming your .hy file is the example module you imported.
I'm relatively new to Python and am trying to analyze an entire folder of netCDF files. When I try to run my code I get the key error: u'satcode'. Here is my code:
import netCDF4 as nc
import glob
import numpy as np
filenames = []
for name in glob.glob("/Users/my_name/Desktop/ISCCP/*"):
print name
filenames.append(name)
# below reads multiple files (file_list)
f = nc.MFDataset(filenames)
I know the error is with f = nc.MFDataset(filenames), but I don't know why.
My traceback says:
runfile('/Users/my_name/.spyder/West_Coast_Model.py', wdir='/Users/my_name/.spyder')
/Users/my_name/Desktop/ISCCP/ISCCP-Basic.HGG.v01r00.GLOBAL.1983.07.01.0000.GPC.10KM.CS00.EA1.00 (5).nc
/Users/my_name/Desktop/ISCCP/ISCCP-Basic.HGH.v01r00.GLOBAL.1983.07.99.0300.GPC.10KM.CS00.EA1.00.nc
/Users/my_name/Desktop/ISCCP/ISCCP-Basic.HGH.v01r00.GLOBAL.1983.07.99.0600.GPC.10KM.CS00.EA1.00.nc
/Users/my_name/Desktop/ISCCP/ISCCP-Basic.HGH.v01r00.GLOBAL.1983.07.99.0900.GPC.10KM.CS00.EA1.00.nc
/Users/my_name/Desktop/ISCCP/ISCCP-Basic.HGH.v01r00.GLOBAL.1983.07.99.1200.GPC.10KM.CS00.EA1.00.nc
/Users/my_name/Desktop/ISCCP/ISCCP-Basic.HGH.v01r00.GLOBAL.1983.07.99.1500.GPC.10KM.CS00.EA1.00.nc
/Users/my_name/Desktop/ISCCP/ISCCP-Basic.HGH.v01r00.GLOBAL.1983.07.99.1800.GPC.10KM.CS00.EA1.00.nc
/Users/my_name/Desktop/ISCCP/ISCCP-Basic.HGH.v01r00.GLOBAL.1983.07.99.2100.GPC.10KM.CS00.EA1.00.nc
/Users/my_name/Desktop/ISCCP/ISCCP-Basic.HGH.v01r00.GLOBAL.1983.08.99.0000.GPC.10KM.CS00.EA1.00.nc
Traceback (most recent call last):
File "", line 1, in
runfile('/Users/my_name/.spyder/West_Coast_Model.py', wdir='/Users/my_name/.spyder')
File "/Users/my_name/anaconda2/lib/python2.7/site-packages/spyder/utils/site/sitecustomize.py", line 705, in runfile
execfile(filename, namespace)
File "/Users/my_name/anaconda2/lib/python2.7/site-packages/spyder/utils/site/sitecustomize.py", line 94, in execfile
builtins.execfile(filename, *where)
File "/Users/my_name/.spyder/West_Coast_Model.py", line 20, in
f = MFDataset(filenames)
File "netCDF4/_netCDF4.pyx", line 5888, in >netCDF4._netCDF4.MFDataset.init
KeyError: u'satcode'
I think I figured out the problem. The 0th term in the files was corrupted, so I redownloaded it and converted it into netCDF4_CLASSIC and it worked.
When I execute the following statement in my code on my Mac OS X
import json, nltk, requests, time, smtplib, uuid
I have the followiong error:
18/01/22 22:03:15 INFO TaskSetManager: Lost task 235.0 in stage 4.0 (TID 16) on executor localhost: org.apache.spark.api.python.PythonException (Traceback (most recent call last):
File "/usr/local/spark/python/lib/pyspark.zip/pyspark/worker.py", line 98, in main
command = pickleSer._read_with_length(infile)
File "/usr/local/spark/python/lib/pyspark.zip/pyspark/serializers.py", line 164, in _read_with_length
return self.loads(obj)
File "/usr/local/spark/python/lib/pyspark.zip/pyspark/serializers.py", line 422, in loads
return pickle.loads(obj)
File "utils.py", line 6, in <module>
import json, nltk, requests, time, smtplib, uuid
File "/Library/Python/2.7/site-packages/nltk/__init__.py", line 114, in <module>
from nltk.collocations import *
File "/Library/Python/2.7/site-packages/nltk/collocations.py", line 39, in <module>
from nltk.metrics import ContingencyMeasures, BigramAssocMeasures, TrigramAssocMeasures
File "/Library/Python/2.7/site-packages/nltk/metrics/__init__.py", line 16, in <module>
from nltk.metrics.scores import (accuracy, precision, recall, f_measure,
File "/Library/Python/2.7/site-packages/nltk/metrics/scores.py", line 16, in <module>
from scipy.stats.stats import betai
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/scipy/stats/__init__.py", line 324, in <module>
from .stats import *
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/scipy/stats/stats.py", line 242, in <module>
import scipy.special as special
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/scipy/special/__init__.py", line 531, in <module>
from ._ufuncs import *
File "numpy.pxd", line 155, in init scipy.special._ufuncs (scipy/special/_ufuncs.c:19983)
ValueError: numpy.dtype has the wrong size, try recompiling
As you can see from log, I'm using python 2,7 and pyspark (spark 1.6).
Maybe the problem is related to the fact that the software tries to use OSX system Python that use a specific version of numpy and I'm not able to understand how can avoid this.
Anyone can help me?
At this link: ValueError: numpy.dtype has the wrong size, try recompiling
the problem is related to the binary distribution of packages that are compiled against a recent version of numpy.
In my case it seems that spark refer the OSX system python ("/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/scipy/stats/stats.py") instead of the "/Library/Python/2.7" i'm using in my virtual env.
When I am working with ELM(extreme learning machine) in python, I came into this problem:ImportError: cannot import name atleast2d_or_csr.The details of error is listed as follows:
C:\Users\sherlock\Anaconda2\lib\site-packages\sklearn\cross_validation.py:44: DeprecationWarning: This module was deprecated in version 0.18 in favor of the model_selection module into which all the refactored classes and functions are moved. Also note that the interface of the new CV iterators are different from that of this module. This module will be removed in 0.20.
"This module will be removed in 0.20.", DeprecationWarning)
Traceback (most recent call last):
File "<ipython-input-50-dad0703e9d35>", line 1, in <module>
runfile('C:/Users/sherlock/Desktop/Ensemble Learnig/Python-ELM-master
/plot_elm_comparison.py', wdir='C:/Users/sherlock/Desktop/EnsembleLearnig
/Python-ELM-master')
File "C:\Users\sherlock\Anaconda2\lib\site-packages\spyder\utils
\site\sitecustomize.py", line 866, in runfile
execfile(filename, namespace)
File "C:\Users\sherlock\Anaconda2\lib\site-packages\spyder\utils
\site\sitecustomize.py", line 87, in execfile
exec(compile(scripttext, filename, 'exec'), glob, loc)
File "C:/Users/sherlock/Desktop/Ensemble Learnig/Python-ELM-master
/plot_elm_comparison.py", line 75, in <module>
from elm import ELMClassifier
File "elm.py", line 34, in <module>
from random_hidden_layer import SimpleRandomHiddenLayer
File "random_hidden_layer.py", line 27, in <module>
from sklearn.utils import check_random_state, atleast2d_or_csr
ImportError: cannot import name atleast2d_or_csr
The concerned statement may be:
from sklearn.utils import check_random_state, atleast2d_or_csr
Replace the following:
from sklearn.utils import check_random_state, atleast2d_or_csr
with this:
from sklearn.utils import check_random_state, check_array
Reference: link