I wrote a python program that upload an excel file to SAS dataset on server. I tested it on my laptop and a few other people's laptop it worked fine. But when I was testing that on one of my colleague's PC I got the following message:
Traceback (most recent call last):
File "call_sas_program.py", line 56, in
subprocess.call(["sasgsub", "-gridsubmitpgm", upload_excel.sas])
File "/opt/packages/anaconda/lib/python2.7/subprocess.py", line 523, in call
return Popen(*popenargs, **kwargs).wait()
File "/opt/packages/anaconda/lib/python2.7/subprocess.py", line 711, in init errread, errwrite)
File "/opt/packages/anaconda/lib/python2.7/subprocess.py", line 1343, in _execute_child
raise child_exception
OSError: [Errno 13] Permission denied
I used python's "subprocess". It looks like a permission issue with the subprocess, but I suspect it's the permission to create SAS table. Has anyone run into this problem before? And how to solve it?
Thanks!
Related
I write a python script to process some data in excel file and I use tkinter to generate a UI to input some paramaters, including input file path and output file path.
I use pyinstaller to package the script into exe. When I run the exe and input the paramaters in the UI, the following error appears:
Exception in Tkinter callback
Traceback (most recent call last):
File "tkinter\__init__.py", line 1892, in __call__
File "ut_calculate_tool.py", line 130, in calculate_data
File "styleframe\style_frame.py", line 318, in ExcelWriter
File "pandas\io\excel\_openpyxl.py", line 52, in __init__
File "pandas\io\excel\_base.py", line 925, in __init__
File "pandas\io\common.py", line 711, in get_handle
PermissionError: [Errno 13] Permission denied: 'C:/Users/XinDong/Documents/UT Calculate'
The path 'C:/Users/XinDong/Documents/UT Calculate' is the output path I typed into the UI.
Does anyone know how to deal with the bug? Thanks in advance.
Cause of the error is the logic of my code, not pyinstaller, I should pass a file name to the backend, not a folder...
When running either command:
sudo serverless package or sudo serverless deploy
I get the following traceback:
Error: ERROR: Exception: Traceback (most recent call last): File
“/var/lang/lib/python3.6/shutil.py”, line 550, in move os.rename(src,
real_dst) OSError: [Errno 18] Invalid cross-device link:
‘/tmp/pip-target-wqc5grcw/lib/python/setuptools’ ->
‘/var/task/setuptools’
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File
“/var/lang/lib/python3.6/site-packages/pip/_internal/cli/base_command.py”,
line 228, in _main status = self.run(options, args) File
“/var/lang/lib/python3.6/site-packages/pip/_internal/cli/req_command.py”,
line 182, in wrapper return func(self, options, args) File
“/var/lang/lib/python3.6/site-packages/pip/_internal/commands/install.py”,
line 456, in run options.target_dir, target_temp_dir, options.upgrade
File
“/var/lang/lib/python3.6/site-packages/pip/_internal/commands/install.py”,
line 514, in _handle_target_dir target_item_dir File
“/var/lang/lib/python3.6/shutil.py”, line 561, in move symlinks=True)
File “/var/lang/lib/python3.6/shutil.py”, line 321, in copytree
os.makedirs(dst) File “/var/lang/lib/python3.6/os.py”, line 220, in
makedirs mkdir(name, mode) PermissionError: [Errno 13] Permission
denied: ‘/var/task/setuptools’
I’ve created several different projects and they work locally but they never progress beyond this invalid cross-link device Error when trying to deploy or package.
What are my options?
Edit: I tried nuking my virtualenv, uninstalling/re-installing serverless-python-requirements, deleting/re-pulling the lambci/lambda Docker image, no dice.
Then, I stumbled on this GH issue. As hinted in it, the experimental Docker feature Use gRPC FUSE for file sharing seems to be the cause. I've switched it off in the Docker Preferences for now and deploys are successful.
I just had a similar problem. See this issue for a possible solution.
In summary,
Remove all cached packages in /Library/Caches/serverless-python-requirements/
Remove existing docker image lambci/lambda build-python3.8
I am simply testing how to call external .py files from one .py file.
I have 2 .py files, both in the same directory. Here is the code for the main one (runext.py suppose to call ext.py):
import subprocess
subprocess.call("/Users/training/PycharmProjects/MarcouFirstProject/ext.py")
ext.py is just print("hey this actually worked")
However, every time I run runext.py, I get this error message:
Traceback (most recent call last):
File "/Users/training/PycharmProjects/MarcouFirstProject/runext.py", line 2, in <module>
subprocess.call("/Users/training/PycharmProjects/MarcouFirstProject/ext.py")
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/subprocess.py", line 557, in call
with Popen(*popenargs, **kwargs) as p:
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/subprocess.py", line 947, in __init__
restore_signals, start_new_session)
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/subprocess.py", line 1551, in _execute_child
raise child_exception_type(errno_num, err_msg)
PermissionError: [Errno 13] Permission denied
I don't know why it denies permission. This is on a school computer (I'm in a programming class) if that helps.
Thanks.
You don't have the permissions to execute the file /Users/training/PycharmProjects/MarcouFirstProject/ext.py
You can add the permission +x by using chmod:
chmod +x /Users/training/PycharmProjects/MarcouFirstProject/ext.py
Or, you can use python explicitly:
import subprocess
subprocess.call("python /Users/training/PycharmProjects/MarcouFirstProject/ext.py")
So I have a python script that produces a networkx graph and exports it as .graphml and I want script to also be able to open cytoscape with the network loaded without any work on the users part. I understand:
cytoscape.bat -N C:\Somepath\with\a\networkx.graphml
and it works fine when I use it. As does:
cd "C:\Program Files\Cytoscape_v3.0.0"
cytoscape.bat
However, I can't seem to get either os.system or subprocess to run properly, my current configuration is:
p = subprocess.Popen("cytoscape.bat", cwd="C:/Program Files/Cytoscape_v3.0.0")
stdout, stderr = p.communicate()
But the throws a file-not-found-exception.
I've been reading up on other stackoverflow posts and python docs on running .bats and doing cmd operations, and can get the basics to work. However, this seems somewhat more complicated, and I'm not sure where I'm going wrong!
As requested I exceptions:
The file not found and incorrect path exceptions:
Traceback (most recent call last):
File "CytoScapeExporter.py", line 219, in <module>
p = subprocess.Popen("cytoscape.bat", cwd="\"C:/Program Files/Cytoscape_v3.0
.0\"")
File "C:\Python27\lib\subprocess.py", line 679, in __init__
errread, errwrite)
File "C:\Python27\lib\subprocess.py", line 896, in _execute_child
startupinfo)
WindowsError: [Error 267] The directory name is invalid
Traceback (most recent call last):
File "CytoScapeExporter.py", line 219, in <module>
p = subprocess.Popen("cytoscape.bat", cwd="C:/Program Files/Cytoscape_v3.0.0
")
File "C:\Python27\lib\subprocess.py", line 679, in __init__
errread, errwrite)
File "C:\Python27\lib\subprocess.py", line 896, in _execute_child
startupinfo)
WindowsError: [Error 2] The system cannot find the file specified
A slightly different JVM error, it is produced by this code:
os.system("\"C:/Program Files/Cytoscape_v3.0.0/cytoscape.bat\"")
Error: missing `server' JVM at `C:\Program Files (x86)\Java\jre7\bin\server\jvm.
dll'.
Please install or use the JRE or JDK that contains these missing components.
C:\Program Files\Cytoscape_v3.0.0
From the documentation:
"If cwd is not None, the child’s current directory will be changed to cwd before it is executed. Note that this directory is not considered when searching the executable, so you can’t specify the program’s path relative to cwd."
You have to pass the full path of the command to subprocess.Popen.
i installed python-nmap-0.1.4.tar.gz in pyhton27 in window. When i ran this http://codepad.org/vTu1Uw7I script, i got a few error. What those error mean?. Are those error happened because i used python-nmap-0.1.4.tar.gz in windows?.
Here is the error
Traceback (most recent call last):
File "C:/Python27/Lib/site-packages/nmap/run-nmap.py", line 3, in <module>
nm = nmap.PortScanner() # instantiate nmap.PortScanner object
File "C:/Python27/Lib/site-packages/nmap\nmap.py", line 118, in __init__
p = subprocess.Popen(['nmap', '-V'], bufsize=10000, stdout=subprocess.PIPE)
File "C:\Python27\lib\subprocess.py", line 711, in __init__
errread, errwrite)
File "C:\Python27\lib\subprocess.py", line 948, in _execute_child
startupinfo)
WindowsError: [Error 2] The system cannot find the file specified
Here is the subprocess.py script
http://codepad.org/SpbV8muR
Seems that python-nmap is meant to be run on Linux… but you can still try to make it work on Windows. The problem is that it is trying to call nmap but the binary is not found in PATH.
Add the directory with nmap executable to you PATH variable. Here is a HOWTO.