[英]Write permission running Python in Notepad++
I'm using Winpython on Windows 10 and notepad++, and want to run the following Python code: 我在Windows 10和notepad ++上使用Winpython,并希望运行以下Python代码:
import wave, struct, math
sampleRate = 44100.0 # hertz
duration = 1.0 # seconds
frequency = 440.0 # hertz
wavef = wave.open('sound.wav','w')
wavef.setnchannels(1) # mono
wavef.setsampwidth(2)
wavef.setframerate(sampleRate)
for i in range(int(duration * sampleRate)):
value = int(32767.0*math.cos(frequency*math.pi*float(i)/float(sampleRate)))
data = struct.pack('<h', value)
wavef.writeframesraw( data )
wavef.writeframes('')
wavef.close()
However I get the following error: 但是我收到以下错误:
Traceback (most recent call last):
File "C:\Users\HP\Desktop\WinPython-64bit-2.7.10.3\robin\sound\wav_00.py", line 7, in <module>
wavef = wave.open('sound.wav','w')
File "C:\Users\HP\Desktop\WinPython-64bit-2.7.10.3\python-2.7.10.amd64\lib\wave.py", line 513, in open
return Wave_write(f)
File "C:\Users\HP\Desktop\WinPython-64bit-2.7.10.3\python-2.7.10.amd64\lib\wave.py", line 308, in __init__
f = __builtin__.open(f, 'wb')
IOError: [Errno 13] Permission denied: 'sound.wav'
I'm running the script using C:\\Users\\HP\\Desktop\\WinPython-64bit-2.7.10.3\\python-2.7.10.amd64\\python.exe -i "$(FULL_CURRENT_PATH)"
我正在使用C:\\Users\\HP\\Desktop\\WinPython-64bit-2.7.10.3\\python-2.7.10.amd64\\python.exe -i "$(FULL_CURRENT_PATH)"
运行脚本C:\\Users\\HP\\Desktop\\WinPython-64bit-2.7.10.3\\python-2.7.10.amd64\\python.exe -i "$(FULL_CURRENT_PATH)"
When I run the script outside of the Winpython folder with my registered Python installation it works fine, but I want to make use of packages that are installed in the Winpython version, so this solution is not adequate 当我使用注册的Python安装程序在Winpython文件夹外部运行脚本时,它可以正常工作,但是我想利用Winpython版本中安装的软件包,因此此解决方案不够用
Please could someone explain how to make this work? 请有人可以解释如何进行这项工作吗?
Try running as administrator. 尝试以管理员身份运行。
If you running from the windows command prompt: 如果从Windows命令提示符运行:
Right click windows button 右键单击Windows按钮
Select "Command Prompt(Admin)" 选择“命令提示符(管理员)”
Execute the script 执行脚本
Hope this helps 希望这可以帮助
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.