I have this code:
import random
import matplotlib.pyplot as plotttt
def simular (N):
Nd=N
c=0
while Nd>(N/2-1):
r=random.uniform(0,1)
if r<Nd/float(N):
Nd=Nd-1
else:
Nd=Nd+1
c+=1
return c
def main ():
Nmax=400
repeticiones=100
x=[]
y=[]
for j in range (2,Nmax):
promedio=0
for i in range (0,repeticiones):
promedio+=simular(j)
y.append(promedio/repeticiones)
x.append(j)
plotttt.plot (x,y,"bo")
plotttt.show()
main()
But when I try to run in through terminal the next error appears:
Traceback (most recent call last):
File "<frozen importlib._bootstrap>", line 1519, in _find_and_load_unlocked
AttributeError: 'module' object has no attribute '__path__'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/opt/local/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/site-packages/matplotlib/__init__.py", line 124, in <module>
import pyparsing
File "/opt/local/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/site-packages/pyparsing.py", line 65, in <module>
import string.ascii_lowercase
ImportError: No module named 'string.ascii_lowercase'; string is not a package
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "simulacion.py", line 2, in <module>
import matplotlib.pyplot as plotttt
File "/opt/local/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/site-packages/matplotlib/__init__.py", line 126, in <module>
raise ImportError("matplotlib requires pyparsing")
ImportError: matplotlib requires pyparsing
Vicente-Gomezs-MacBook-Pro:Python Vicente$
However no problem occurs when I run it on IDLE. Ideas?
Related
I am trying to run this text-to-speech program
I followed instructions verbatim, but when I go to run the first line of code (below)
python tortoise/do_tts.py --text "I'm going to speak this" --voice random --preset fast
I get he following error code:
C:\Users\chase\anaconda3\lib\site-packages\torchaudio\_internal\module_utils.py:99: UserWarning: Failed to import soundfile. 'soundfile' backend is not available.
warnings.warn("Failed to import soundfile. 'soundfile' backend is not available.")
C:\Users\chase\anaconda3\lib\site-packages\paramiko\transport.py:219: CryptographyDeprecationWarning: Blowfish has been deprecated
"class": algorithms.Blowfish,
Traceback (most recent call last):
File "C:\Users\chase\anaconda3\lib\site-packages\soundfile.py", line 152, in <module>
_snd = _ffi.dlopen(_libname)
OSError: cannot load library 'C:\Users\chase\anaconda3\Library\bin\sndfile.dll': error 0x7e
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\chase\anaconda3\lib\site-packages\soundfile.py", line 178, in <module>
_snd = _ffi.dlopen(_os.path.join(_path, '_soundfile_data', _packaged_libname))
OSError: cannot load library 'C:\Users\chase\anaconda3\lib\site-packages\_soundfile_data\libsndfile_64bit.dll': error 0x7e
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\chase\tortoise-tts\tortoise\do_tts.py", line 7, in <module>
from api import TextToSpeech, MODELS_DIR
File "C:\Users\chase\tortoise-tts\tortoise\api.py", line 22, in <module>
from tortoise.utils.audio import wav_to_univnet_mel, denormalize_tacotron_mel
File "C:\Users\chase\anaconda3\lib\site-packages\tortoise-2.4.2-py3.9.egg\tortoise\utils\audio.py", line 4, in <module>
import librosa
File "C:\Users\chase\anaconda3\lib\site-packages\librosa-0.9.2-py3.9.egg\librosa\__init__.py", line 209, in <module>
from . import core
File "C:\Users\chase\anaconda3\lib\site-packages\librosa-0.9.2-py3.9.egg\librosa\core\__init__.py", line 6, in <module>
from .audio import * # pylint: disable=wildcard-import
File "C:\Users\chase\anaconda3\lib\site-packages\librosa-0.9.2-py3.9.egg\librosa\core\audio.py", line 8, in <module>
import soundfile as sf
File "C:\Users\chase\anaconda3\lib\site-packages\soundfile.py", line 189, in <module>
_snd = _ffi.dlopen(_libname)
OSError: cannot load library 'libsndfile.dll': error 0x7e
I expected it to run
Try on linux, it works fine for me.
Try 'flask run --help' for help.
Error: While importing "main", an ImportError was raised:
Traceback (most recent call last):
File "/home/anirudh/Downloads/blinktrustapis-main/main.py", line 9, in
from .apis.appServer import AppServer
ImportError: attempted relative import with no known parent package
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/flask/cli.py", line 240, in locate_app
import(module_name)
File "/home/anirudh/Downloads/blinktrustapis-main/main.py", line 11, in
from apis.appServer import AppServer
File "/home/anirudh/Downloads/blinktrustapis-main/apis/appServer.py", line 32, in
from apis.utility import *
File "/home/anirudh/Downloads/blinktrustapis-main/apis/utility.py", line 6, in
from dataprofiler.piiservice.api import ScanTypeEnum, list_detectors, scan_database
File "/home/anirudh/Downloads/blinktrustapis-main/dataprofiler/piiservice/api.py", line 6, in
from dataprofiler.catelogs.api import scan_sources
File "/home/anirudh/Downloads/blinktrustapis-main/dataprofiler/catelogs/api.py", line 13, in
from dataprofiler.catelogs.catalog.db import DbScanner
File "/home/anirudh/Downloads/blinktrustapis-main/dataprofiler/catelogs/catalog/db.py", line 6, in
from databuilder import Scoped
ImportError: cannot import name 'Scoped' from 'databuilder' (/home/anirudh/.local/lib/python3.9/site-packages/databuilder/init.py)
enter image description hereAs can be seen in the traceback the exception occurs when pyaudioconvert is imported. How can this be fixed?
Traceback below:
Traceback (most recent call last):
File "C:\Users\320052863\PycharmProjects\Test\venv\lib\site-packages\pyaudioconvert\__init__.py", line 43, in <module>
assert(bool_which('sox'))
AssertionError
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:/Users/320052863/PycharmProjects/Test/hello.py", line 1, in <module>
import pyaudioconvert
File "C:\Users\320052863\PycharmProjects\Test\venv\lib\site-packages\pyaudioconvert\__init__.py", line 45, in <module>
raise SoxNotInstalled()
pyaudioconvert.SoxNotInstalled
As the error message says, you need to install SoX.
It is also listed as a requirement for pyaudioconvert.
I was trying to get this ConvexHull function running, and I needed numpy (I think) to get it to work. I'm going to try to get numpy uninstalled and reinstalled, but I'm not sure why/how this happened so that I can prevent it from happening again.
While I was running through some of the examples, I decided to stop running from the prompt to save some typing. When I ran the seemingly same bits of code from a file, it returned the following error message:
>>>
Traceback (most recent call last):
File "<frozen importlib._bootstrap>", line 2218, in _find_and_load_unlocked
AttributeError: 'module' object has no attribute '__path__'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:/Python34/numpy.py", line 1, in <module>
from scipy.spatial import ConvexHull
File "C:\Python34\lib\site-packages\scipy\__init__.py", line 61, in <module>
from numpy import show_config as show_numpy_config
File "C:/Python34\numpy.py", line 1, in <module>
from scipy.spatial import ConvexHull
File "C:\Python34\lib\site-packages\scipy\spatial\__init__.py", line 90, in <module>
from .kdtree import *
File "C:\Python34\lib\site-packages\scipy\spatial\kdtree.py", line 8, in <module>
import scipy.sparse
File "C:\Python34\lib\site-packages\scipy\sparse\__init__.py", line 212, in <module>
from .base import *
File "C:\Python34\lib\site-packages\scipy\sparse\base.py", line 11, in <module>
from scipy._lib.six import xrange
File "C:\Python34\lib\site-packages\scipy\_lib\__init__.py", line 14, in <module>
from numpy.testing import Tester
ImportError: No module named 'numpy.testing'; 'numpy' is not a package
>>> ================================ RESTART ================================
Now, when I type import numpy from the prompt, it returns:
>>> import numpy
Traceback (most recent call last):
File "<pyshell#40>", line 1, in <module>
import numpy
File "C:/Python34\numpy.py", line 1, in <module>
from scipy.spatial import ConvexHull
File "C:\Python34\lib\site-packages\scipy\__init__.py", line 61, in <module>
from numpy import show_config as show_numpy_config
ImportError: cannot import name 'show_config'
The entire setup was running without issue a few minutes ago, and I am unsure exactly why this all stopped.
The full text of my commands is here. The file was short, C:\Python34\numpy.py with the following contents:
from scipy.spatial import ConvexHull
import numpy as np
points = np.random.rand(30,2)
Change the file name to something different than numpy.py.
I am using python3.4.1 in win7
And I wana use matplotlib.
but this error code has occured.
Could you help me?
>>> text4.dispersion_plot(["citizens", "democracy", "freedom", "duties", "America"])
Traceback (most recent call last):
File "C:\Python34\lib\site-packages\nltk\draw\dispersion.py", line 25, in dispersion_plot
import pylab
File "C:\Python34\lib\site-packages\pylab.py", line 1, in <module>
from matplotlib.pylab import *
File "C:\Python34\lib\site-packages\matplotlib\__init__.py", line 105, in <module>
import six
ImportError: No module named 'six'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<pyshell#5>", line 1, in <module>
text4.dispersion_plot(["citizens", "democracy", "freedom", "duties", "America"])
File "C:\Python34\lib\site-packages\nltk\text.py", line 445, in dispersion_plot
dispersion_plot(self, words)
File "C:\Python34\lib\site-packages\nltk\draw\dispersion.py", line 27, in dispersion_plot
raise ValueError('The plot function requires the matplotlib package (aka pylab).'
ValueError: The plot function requires the matplotlib package (aka pylab).See
http://matplotlib.sourceforge.net/
>>>