Below is a piece of python code that is causing an error. Can someone help with a solution who might have ran into this issue before?
>>> from subprocess import call
>>> call("svn update C:/folder1/subfoler1/ --non-interactive -q")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "D:\Python34\lib\subprocess.py", line 537, in call
with Popen(*popenargs, **kwargs) as p:
File "D:\Python34\lib\subprocess.py", line 859, in __init__
restore_signals, start_new_session)
File "D:\Python34\lib\subprocess.py", line 1112, in _execute_child
startupinfo)
FileNotFoundError: [WinError 2] The system cannot find the file specified```
I have gone through various other posts on similar issue but nothing related to svn update call. I haven't tried adding shell=True as this wasn't the best solution as suggested by many in this forum that it might be a security issue.
Found the solution: I did not have SVN command line tools installed on the system. The sub-process couldn't call the SVN commands.
Related
I'm trying to make an Iperf3 python wrapper work in cygwin. The wrapper requires Iperf3 to be installed and needs a library called "libiperf.so.0" to work. In Ubuntu, the wrapper automatically finds this Iperf3 library. In cygwin, I compiled, built, and installed Iperf3 from source and it is working, so I'm assuming the library asked by the wrapper can be found.
However I could only find libiperf.a and libiperf.la on cygwin, not libiperf.so.0, and, from what I researched, those are the libraries used by Iperf when you compile, build and install it in cygwin.
So I tried passing libiperf.a and libiperf.la as libraries to the python wrapper. But I get either "OSError: Permission Dienied" (when passing libiperf.a) or "OSError: Exec format error" (when passing libiperf.la), followed by another "OSError: Couldn't find shared library <path_to_library>, is iperf3 installed?"
Here's the complete error output when i pass libiperf.la as library:
>>> client = iperf3.Client(lib_name="/cygdrive/c/cygwin64/usr/local/lib/libiperf.la")
Exception ignored in: <function IPerf3.__del__ at 0x6fffffd1b700>
Traceback (most recent call last):
File "/usr/local/lib/python3.8/site-packages/iperf3/iperf3.py", line 213, in __del__
os.close(self._stdout_fd)
AttributeError: 'Client' object has no attribute '_stdout_fd'
Traceback (most recent call last):
File "/usr/local/lib/python3.8/site-packages/iperf3/iperf3.py", line 106, in __init__
self.lib = cdll.LoadLibrary(lib_name)
File "/usr/lib/python3.8/ctypes/__init__.py", line 451, in LoadLibrary
return self._dlltype(name)
File "/usr/lib/python3.8/ctypes/__init__.py", line 373, in __init__
self._handle = _dlopen(self._name, mode)
OSError: Exec format error
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.8/site-packages/iperf3/iperf3.py", line 418, in __init__
super(Client, self).__init__(role='c', *args, **kwargs)
File "/usr/local/lib/python3.8/site-packages/iperf3/iperf3.py", line 108, in __init__
raise OSError(
OSError: Couldn't find shared library /cygdrive/c/cygwin64/usr/local/lib/libiperf.la, is iperf3 installed?
Here's the complete error output when i pass libiperf.a as library:
>>> client = iperf3.Client(lib_name="/cygdrive/c/cygwin64/usr/local/lib/libiperf.a")
Exception ignored in: <function IPerf3.__del__ at 0x6fffffd1b700>
Traceback (most recent call last):
File "/usr/local/lib/python3.8/site-packages/iperf3/iperf3.py", line 213, in __del__
os.close(self._stdout_fd)
AttributeError: 'Client' object has no attribute '_stdout_fd'
Traceback (most recent call last):
File "/usr/local/lib/python3.8/site-packages/iperf3/iperf3.py", line 106, in __init__
self.lib = cdll.LoadLibrary(lib_name)
File "/usr/lib/python3.8/ctypes/__init__.py", line 451, in LoadLibrary
return self._dlltype(name)
File "/usr/lib/python3.8/ctypes/__init__.py", line 373, in __init__
self._handle = _dlopen(self._name, mode)
OSError: Permission denied
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.8/site-packages/iperf3/iperf3.py", line 418, in __init__
super(Client, self).__init__(role='c', *args, **kwargs)
File "/usr/local/lib/python3.8/site-packages/iperf3/iperf3.py", line 108, in __init__
raise OSError(
OSError: Couldn't find shared library /cygdrive/c/cygwin64/usr/local/lib/libiperf.a, is iperf3 installed?
According to this question the Exec format error means the file format is not supported by the OS, but Iperf3 is working correctly on cygwin. So for some reason the libiperf.la or libiperf.a are working for Iperf3 but arent accepted by the wrapper.
Also could I trust the "OSError: Exec format error"? Because down in the error output it says the library couldn't be found. If the library couldn't even be found how can it say there was a format error?
I also tried
ln ./libiperf.a ./libiperf.so.0
and
ln ./libiperf.la ./libiperf.so.0
trying to trick the wrapper into accepting the libraries but I keep getting the same errors as before.
I feel like this wrapper cant be run in cygwin because of the different libraries iperf3 uses when its installed in the cygwin environment, but maybe not. Am I missing something to make this work?
I am learning Python 3 using a Udemy course. One of the course modules asks us to install Pyperclip in order to try out simple code is the console.
import pyperclip
pyperclip.copy(‘Test’)
pyperclip.paste()
I believe this should output the word Test in the console.
I did the following:
Installed Stash
Installed Pyperclip by running the command ‘pip install Pyperclip’ from within Stash. Package installed fine
Went back to console and ran the import Pyperclip command. No errors
However, when I try to run the function Pyperclip.copy() or .paste() I get an error:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/private/var/mobile/Containers/Shared/AppGroup/C6F5AC74-E13C-4A33-95BA-F075B9E680F9/Pythonista3/Documents/site-packages-3/pyperclip/__init__.py", line 120, in copy_osx_pbcopy
stdin=subprocess.PIPE, close_fds=True)
File "/var/containers/Bundle/Application/479FB713-67AD-4A41-9180-71A1C27C61E8/Pythonista3.app/Frameworks/Py3Kit.framework/pylib/subprocess.py", line 708, in __init__
restore_signals, start_new_session)
File "/var/containers/Bundle/Application/479FB713-67AD-4A41-9180-71A1C27C61E8/Pythonista3.app/Frameworks/Py3Kit.framework/pylib/subprocess.py", line 1261, in _execute_child
restore_signals, start_new_session, preexec_fn)
PermissionError: [Errno 1] Operation not permitted
I looked around for similar errors on stack overflow but the issues/ answers don’t seem to fit my situation. What am I doing wrong?
Pyperclip is not supported by Pythonista. Try their built in module, clipboard. http://omz-software.com/pythonista/docs/ios/clipboard.html
I want to use pydf to generate a pdf in Python 3. I tested it out in terminal (Mac) and received the below error. Does anyone know why and what to do?
If possible, I would like to stick with pydf and not have to move to another library.
.
I downloaded the Mac wkhtmltopdf version from https://wkhtmltopdf.org/downloads.html
As well as pydf from pip install python-pdf
>>> import pydf
>>> pydf.generate_pdf('hello')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pydf/wkhtmltopdf.py", line 145, in generate_pdf
p = _execute_wk(*cmd_args, input=html.encode())
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pydf/wkhtmltopdf.py", line 30, in _execute_wk
return subprocess.run(wk_args, input=input, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/subprocess.py", line 453, in run
with Popen(*popenargs, **kwargs) as process:
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/subprocess.py", line 756, in __init__
restore_signals, start_new_session)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/subprocess.py", line 1499, in _execute_child
raise child_exception_type(errno_num, err_msg, err_filename)
OSError: [Errno 8] Exec format error: '/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pydf/bin/wkhtmltopdf'
>>>
This is because the binary which is packaged with python-pdf is for linux and will not execute on MacOS, this explained briefly in the README.
Luckily the solution is easy, you need to install wkhtmltopdf via homebrew or similar, then set the WKHTMLTOPDF_PATH environment variable to point to it.
In my case that's
export WKHTMLTOPDF_PATH=/usr/local/bin/wkhtmltopdf
I'm a non-programmer trying to use Automate the Boring Stuff with Python to do exactly that. I watched all the videos and thought I was ready, but as I tried to get going I'm stuck on square zero.
I'm on a Mac OSx Mojave Version 10.14.2
Successfully installed Python 3.7.2
I'm trying to follow this chapter: http://automatetheboringstuff.com/chapter11/
Successfully installed Selenium because:
import selenium
does not give an error.
but when I run this:
from selenium import webdriver
browser = webdriver.Firefox()
I get this error:
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/selenium/webdriver/common/service.py", line 76, in start
stdin=PIPE)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/subprocess.py", line 775, in __init__
restore_signals, start_new_session)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/subprocess.py", line 1522, in _execute_child
raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'your\\path\\geckodriver.exe': 'your\\path\\geckodriver.exe'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<pyshell#3>", line 1, in <module>
driver = webdriver.Firefox(executable_path=r'your\path\geckodriver.exe')
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/selenium/webdriver/firefox/webdriver.py", line 164, in __init__
self.service.start()
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/selenium/webdriver/common/service.py", line 83, in start
os.path.basename(self.path), self.start_error_message)
selenium.common.exceptions.WebDriverException: Message: 'your\path\geckodriver.exe' executable needs to be in PATH.
>>> driver = webdriver.Firefox(executable_path=r'your\path\geckodriver.exe')
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/selenium/webdriver/common/service.py", line 76, in start
stdin=PIPE)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/subprocess.py", line 775, in __init__
restore_signals, start_new_session)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/subprocess.py", line 1522, in _execute_child
raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'your\\path\\geckodriver.exe': 'your\\path\\geckodriver.exe'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<pyshell#4>", line 1, in <module>
driver = webdriver.Firefox(executable_path=r'your\path\geckodriver.exe')
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/selenium/webdriver/firefox/webdriver.py", line 164, in __init__
self.service.start()
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/selenium/webdriver/common/service.py", line 83, in start
os.path.basename(self.path), self.start_error_message)
selenium.common.exceptions.WebDriverException: Message: 'your\path\geckodriver.exe' executable needs to be in PATH.
I've tried everything in this: Selenium using Python - Geckodriver executable needs to be in PATH and I don't think it works anymore.
I've installed geckodriver and tried appending it to PATH but nothing seems to work. geckodriver is installed in /usr/local/bin/ and I've appended it to path by running export PATH=$PATH:/path/to/geckodriver and export PATH=$PATH:/usr/local/bin/geckodriver but I keep getting the same error
I've tried having both the newest Firefox and Firefox v46 installed because I read somewhere that it doesn't work after that version.
Any help is much appreciated.
I suggest to install with pip
pip install geckodriver-autoinstaller
and then add this code
import geckodriver_autoinstaller
# Check if the current version of geckodriver exists
# and if it doesn't exist, download it automatically,
# then add geckodriver to path
geckodriver_autoinstaller.install()
Set your executable_path
from selenium import webdriver
webdriver.Firefox(executable_path=r'path\to\geckdriver\geckodriver.exe')
executable_path –
Full path to override which geckodriver binary to use for Firefox 47.0.1 and greater, which defaults to picking up the binary from the system path.
from documentation
Edit: also works on lower versions firefox
Edit 2:
Perhaps you could verify the executable can be found by python itself.
import os.path
os.path.exists(file_path)
I want to write a chess related program, where I need to evaluate moves. For this purpose, I have installed the python stockfish package from https://github.com/zhelyabuzhsky/stockfish.
But when I test even one line, with
from stockfish import Stockfish
stockfish = Stockfish()
I get the error
Traceback (most recent call last):
File "<ipython-input-12-fef147213e5f>", line 1, in <module>
stockfish = Stockfish()
File "C:\Users\ajdin\Anaconda3\lib\site-packages\stockfish.py", line 27, in __init__
stdout=subprocess.PIPE
File "C:\Users\ajdin\Anaconda3\lib\subprocess.py", line 707, in __init__
restore_signals, start_new_session)
File "C:\Users\ajdin\Anaconda3\lib\subprocess.py", line 990, in _execute_child
startupinfo)
FileNotFoundError: [WinError 2] The system cannot find the file specified.
I've also tried the same thing with a similar package from https://github.com/iamjarret/pystockfish with the pystockfish package, but the same error arose. (only now the main code was deep = Engine(depth=20) ).
I've searched online for this error, but couldn't really find a solution. Does anyone know what is wrong, am I missing any files here?
Any more required info, I am happy to give.
In both cases my pathfile "stockfish" was incorrect. It needed the full pathname as argument.