Hi everyone so I have some python code I am trying to run from my terminal (will not work in an IDE) to take a .mp3 file and classify the genre of the song based on the Spectrogram that we are using the librosa library plugin for. The code is from this gitHub: https://github.com/cetinsamet/music-genre-classification .When I use the command prompt specified by the gitHub user who created this app I get this error in my terminal:
(base) Nicos-MacBook-Pro:src nico$ python3 get_genre.py ../test.mp3
Traceback (most recent call last):
File "get_genre.py", line 61, in <module>
main(sys.argv[1:])
File "get_genre.py", line 30, in main
net.load_state_dict(torch.load(MODELPATH, map_location='cpu'))
File "/Users/nico/opt/anaconda3/lib/python3.7/site-packages/torch/serialization.py", line 419, in load
f = open(f, 'rb')
FileNotFoundError: [Errno 2] No such file or directory: '../utils/net.pt'
Here is the command line specified: $ python3 get_genre.py ../test.mp3
The error message quite plainly tells you that the code depends on having a file ../utils/net.pt
Related
I have a weird error message using the download_and_convert_mnist_m.py script from github https://github.com/tensorflow/models/tree/master/research/domain_adaptation/datasets.
The command I am using from the models/research/ folder is
python domain_adaptation/datasets/download_and_convert_mnist_m.py --dataset_dir=~/dsn_data/
The error message is
Traceback (most recent call last):
File "domain_adaptation/datasets/download_and_convert_mnist_m.py", line 237, in <module>
tf.app.run()
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/platform/app.py", line 48, in run
_sys.exit(main(_sys.argv[:1] + flags_passthrough))
File "domain_adaptation/datasets/download_and_convert_mnist_m.py", line 233, in main
run(FLAGS.dataset_dir)
File "domain_adaptation/datasets/download_and_convert_mnist_m.py", line 201, in run
os.path.join(dataset_dir, 'mnist_m', 'mnist_m_train'))
File "domain_adaptation/datasets/download_and_convert_mnist_m.py", line 177, in _get_filenames
for filename in os.listdir(dataset_dir):
OSError: [Errno 2] No such file or directory: '~/dsn_data/mnist_m/mnist_m_train'
I tried several ways:
without creating the path before and without having the data before
create the path before and let it empty
download and unpack data from https://drive.google.com/drive/folders/0B_tExHiYS-0vR2dNZEU4NGlSSW8 at the specified path as described here https://github.com/tensorflow/models/tree/master/research/domain_adaptation
I use
Ubuntu 16.04
Python 2.7
tensorflow 1.4.1
What else can I do.. looks like an pretty simple error but I have no more ideas.
I solved it. The correct command is without the equal sign.
python domain_adaptation/datasets/download_and_convert_mnist_m.py --dataset_dir=~/dsn_data/
Found no solution here on stackoverflow yet. In the threads I read, where this problem is considered, the problem was triggered by a wrong path. But in my case, the path should be correct, since I copied it to the windows navigation line and it worked.
The error message looks as follows:
Traceback (most recent call last):
File "C:\Users\micha\Dropbox\10. Semester\Fabios_error_bound\python_new_pc\feb_error_calculation_and_plotting\feb_error_calculation_and_plotting\feb_error_calculation_and_plotting.py", line 99, in <module>
np.savetxt(os.path.join(working_directory,error_folder,current_name.replace('.txt','')+'error_pop11.txt'),error_pop11, fmt='%20.14f')
File "C:\Python27amd64\lib\site-packages\numpy\lib\npyio.py", line 1194, in savetxt
fh = open(fname, 'w')
IOError: [Errno 2] No such file or directory: 'C:\\Users\\micha\\Dropbox\\10. Semester\\Fabios_error_bound\\python_new_pc\\feb_error_calculation_and_plotting\\feb_error_calculation_and_plotting\\error2\\ses_pop_site_eb__ohmic_lam50_gam100_T100_SD_ohmic_lam50_gam100_T100_angle39_Chl658_Egap0_J100_M2_K0_L8error_pop11.txt'
Furthermore, it works on my PC, but not on my notebook. In both cases I'm using Visual Studio with Python 3.5 and 3.6, respectively (with 2.7 it also doesn't work on my Notebook).
Does anybody has a clue?
I dont have much experience in python, so it might be a stupid question.
Im trying to write to a file in my script, if I run the script from his folder, it works, however if I run it from another folder, I have an error 13 persmission denied
i.e. in cmd :
cd C:\Users\user010\Perforce\Build\LS3\
py Build_jenkins.py
works but
cd C:\Program Files (x86)\Jenkins\workspace\LC3.3 Test\Qt\main
py C:\Users\user010\Perforce\Build\LS3\Build_jenkins.py
doesnt work. I have tried moving the script and the file to a public folder, same error :
Traceback (most recent call last):
File "C:\Users\Public\Documents\Build\LS3\Build_jenkins.py", line 159, in <module>
Variables.Sauvegarder()
File "C:/Users/Public/Documents/Build/LS3/../Common\Variables.py", line 87, in Sauvegarder
gArbre.write( NOM_FICHIER )
File "C:\Python34\lib\xml\etree\ElementTree.py", line 761, in write
with _get_writer(file_or_filename, encoding) as write:
File "C:\Python34\lib\contextlib.py", line 59, in __enter__
return next(self.gen)
File "C:\Python34\lib\xml\etree\ElementTree.py", line 798, in _get_writer
errors="xmlcharrefreplace")
PermissionError: [Errno 13] Permission denied: 'Variables.xml'
The code is Variables.Sauvegarder() in my main file and in Variables :
import xml.etree.ElementTree as ET
gArbre = ET.parse( "Variables.xml" )
def Sauvegarder():
gArbre.write( "Variables.xml")
Edit : important detail I forgot to mention, the file im writing to is located in the script folder (C:/Users/Public/Documents/Build/LS3/../Common\Variables.xml)
To be honest, I'm not sure about Windows computers (for a mac or other linux-based system you'd use sudo), but I would recommend trying to run the command as an administrator (use the runas command plus the name of an account with admin priveledges.) That should hopefully fix the error you're getting.
I am quite new to Python and I am having problems opening a file in Python.
I want to open a text file called 'coolStuff' in a Folder on my Desktop and this is how I type in the command but I still get an error message. The file exists and so I do not understand why I get that error message.
open("coolStuff.txt","r")
Traceback (most recent call last):
File "<pyshell#11>", line 1, in <module>
open("coolStuff.txt","r")
FileNotFoundError: [Errno 2] No such file or directory: 'coolStuff.txt'
If you want to simply supply a filename like coolStuff.txt without also providing a full directory, then you have to make sure that Python is running in the same directory as the file. If you aren't sure what directory Python is running in, try this:
import os
print(os.getcwd())
You have two options:
let's say your file is in C:\path\to\dir\coolStuff.txt
1.
open(r'C:\path\to\dir\coolStuff.txt','r')
2.
import os
os.chdir(r'c:\path\to\dir')
open('coolStuff.txt', 'r')
Because the file you want to open is not in the current directory.You can find the file 'coolStuff.txt' in the terminal and launch your python environment at the same directory.
I would like to use the Odoo Framework from the shell.
I installed the module "Shell command backport" (technical name: shell), but I couldn't make it work.
$ ./odoo.py shell --addons-path=/opt/odoo_8/src/linked-addons -d database_name
Traceback (most recent call last):
File "./odoo.py", line 160, in <module>
main()
File "./odoo.py", line 157, in main
openerp.cli.main()
File "/opt/odoo_8/src/OCA/OCB/openerp/cli/__init__.py", line 58, in main
for m in module.get_modules():
File "/opt/odoo_8/src/OCA/OCB/openerp/modules/module.py", line 351, in get_modules
plist.extend(listdir(ad))
File "/opt/odoo_8/src/OCA/OCB/openerp/modules/module.py", line 346, in listdir
return map(clean, filter(is_really_module, os.listdir(dir)))
OSError: [Errno 2] No such file or directory: '/opt/odoo8/openerp/addons'
Where is defined the path /opt/odoo8/openerp/addons? I checked this similar question as well.
If I don't write the addons path in the command the error appears again.
I read the answer of this other question, I tried the module and the script option but they didn't work. What should I do to make it work? Any hint would help.
Check your .opererp_serverrc for the user you are executing the command as. In the users home directory you will find this file. There may be reference to the addons_path. The path it appears to be looking for /opt/odoo8/openerp/addons differs from what you have specified in your command. I would check your config files.