Python script Traceback - python

Traceback (most recent call last):
File "/data/data/com.termux/files/usr/lib/python3.11/site-packages/psutil/_common.py", line 399, in wrapper
return cache[key]
~~~~~^^^^^
KeyError: (('/proc',), frozenset())
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/data/data/com.termux/files/usr/lib/python3.11/site-packages/psutil/_pslinux.py", line 285, in
set_scputimes_ntuple("/proc")
File "/data/data/com.termux/files/usr/lib/python3.11/site-packages/psutil/_common.py", line 401, in wrapper
ret = cache[key] = fun(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^
File "/data/data/com.termux/files/usr/lib/python3.11/site-packages/psutil/_pslinux.py", line 268, in set_scputimes_ntuple
with open_binary('%s/stat' % procfs_path) as f:
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/data/data/com.termux/files/usr/lib/python3.11/site-packages/psutil/_common.py", line 728, in open_binary
return open(fname, "rb", buffering=FILE_READ_BUFFER_SIZE)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
PermissionError: [Errno 13] Permission denied: '/proc/stat'
Traceback (most recent call last):
File "/data/data/com.termux/files/home/YouTube-Viewer/youtube_viewer.py", line 33, in
from fake_headers import Headers, browsers
ModuleNotFoundError: No module named 'fake_headers'
What's problem ? I don't know

Related

Ib_insync error asyncio.exceptions.TimeoutError while running IB gateaway on server

I'm using docker image to run ib gateaway on remote server, the gateaway is running but when using ib_insync to connect and get data i'm getting asyncio.exceptions.TimeoutError
This is the full log:
Traceback (most recent call last):
File "C:\Users\AppData\Local\Programs\Python\Python39\lib\asyncio\tasks.py", line 688, in _wrap_awaitable
return (yield from awaitable.__await__())
asyncio.exceptions.CancelledError
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\AppData\Local\Programs\Python\Python39\lib\asyncio\tasks.py", line 490, in wait_for
return fut.result()
asyncio.exceptions.CancelledError
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Users\Desktop\tutorial\tutorial\spiders\IB-TEST\main.py", line 11, in <module>
ib.connect('ip', port, clientId=2)
File "C:\Users\Desktop\tutorial\tutorial\spiders\IB-TEST\venv\lib\site-packages\ib_insync\ib.py", line 269, in connect
return self._run(self.connectAsync(
File "C:\Users\Desktop\tutorial\tutorial\spiders\IB-TEST\venv\lib\site-packages\ib_insync\ib.py", line 308, in _run
return util.run(*awaitables, timeout=self.RequestTimeout)
File "C:\Users\Desktop\tutorial\tutorial\spiders\IB-TEST\venv\lib\site-packages\ib_insync\util.py", line 332, in run
result = loop.run_until_complete(task)
File "C:\Users\AppData\Local\Programs\Python\Python39\lib\asyncio\base_events.py", line 642, in run_until_complete
return future.result()
File "C:\Users\Desktop\tutorial\tutorial\spiders\IB-TEST\venv\lib\site-packages\ib_insync\ib.py", line 1626, in connectAsync
await self.client.connectAsync(host, port, clientId, timeout)
File "C:\Users\Desktop\tutorial\tutorial\spiders\IB-TEST\venv\lib\site-packages\ib_insync\client.py", line 216, in connectAsync
await asyncio.wait_for(self.apiStart, timeout)
File "C:\Users\AppData\Local\Programs\Python\Python39\lib\asyncio\tasks.py", line 492, in wait_for
raise exceptions.TimeoutError() from exc
asyncio.exceptions.TimeoutError
Any idea what can cause it?

Access to process information running by others

I'm writing a program in Python to see which process is using a particular file.
import psutil
for i in psutil.process_iter():
print(i)
print(i.open_files())
In it, I learned how to use psutil to identify the files used by process.
This works fine if the same user opens the file.
However, when I become another user, I get the following error.
Traceback (most recent call last):
File "/usr/local/lib/python3.9/site-packages/psutil/_pslinux.py", line 1517, in wrapper
return fun(self, *args, **kwargs)
File "/usr/local/lib/python3.9/site-packages/psutil/_pslinux.py", line 2036, in open_files
path = readlink(file)
File "/usr/local/lib/python3.9/site-packages/psutil/_pslinux.py", line 212, in readlink
path = os.readlink(path)
PermissionError: [Errno 13] Permission denied: '/proc/371/fd/0'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "//main.py", line 4, in <module>
print(i.open_files())
File "/usr/local/lib/python3.9/site-packages/psutil/__init__.py", line 1136, in open_files
return self._proc.open_files()
File "/usr/local/lib/python3.9/site-packages/psutil/_pslinux.py", line 1519, in wrapper
raise AccessDenied(self.pid, self._name)
psutil.AccessDenied: psutil.AccessDenied (pid=371, name='bash')
I'm looking for a solution to this problem by changing permission settings or changing python code.
I would be happy if you could tell me.
root#3b17530ce829:/# ls -al /proc/371/fd/0
ls: cannot read symbolic link '/proc/371/fd/0': Permission denied
lrwx------ 1 hashito hashito 64 Dec 12 01:57 /proc/371/fd/0
There seems to be a problem with the permissions of the target file.
add..
sudo use...
sudo -E python main.py
psutil.Process(pid=1, name='bash', status='sleeping', started='01:23:19')
[]
psutil.Process(pid=327, name='bash', status='sleeping', started='01:51:23')
[]
psutil.Process(pid=370, name='su', status='sleeping', started='01:57:01')
[]
psutil.Process(pid=371, name='bash', status='sleeping', started='01:57:01')
Traceback (most recent call last):
File "/usr/local/lib/python3.9/site-packages/psutil/_pslinux.py", line 1517, in wrapper
return fun(self, *args, **kwargs)
File "/usr/local/lib/python3.9/site-packages/psutil/_pslinux.py", line 2036, in open_files
path = readlink(file)
File "/usr/local/lib/python3.9/site-packages/psutil/_pslinux.py", line 212, in readlink
path = os.readlink(path)
PermissionError: [Errno 13] Permission denied: '/proc/371/fd/0'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "//main.py", line 4, in <module>
print(i.open_files())
File "/usr/local/lib/python3.9/site-packages/psutil/__init__.py", line 1136, in open_files
return self._proc.open_files()
File "/usr/local/lib/python3.9/site-packages/psutil/_pslinux.py", line 1519, in wrapper
raise AccessDenied(self.pid, self._name)
psutil.AccessDenied: psutil.AccessDenied (pid=371, name='bash')
root#3b17530ce829:/# python main.py
psutil.Process(pid=1, name='bash', status='sleeping', started='01:23:19')
[]
psutil.Process(pid=327, name='bash', status='sleeping', started='01:51:23')
[]
psutil.Process(pid=370, name='su', status='sleeping', started='01:57:01')
[]
psutil.Process(pid=371, name='bash', status='sleeping', started='01:57:01')
Traceback (most recent call last):
File "/usr/local/lib/python3.9/site-packages/psutil/_pslinux.py", line 1517, in wrapper
return fun(self, *args, **kwargs)
File "/usr/local/lib/python3.9/site-packages/psutil/_pslinux.py", line 2036, in open_files
path = readlink(file)
File "/usr/local/lib/python3.9/site-packages/psutil/_pslinux.py", line 212, in readlink
path = os.readlink(path)
PermissionError: [Errno 13] Permission denied: '/proc/371/fd/0'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "//main.py", line 4, in <module>
print(i.open_files())
File "/usr/local/lib/python3.9/site-packages/psutil/__init__.py", line 1136, in open_files
return self._proc.open_files()
File "/usr/local/lib/python3.9/site-packages/psutil/_pslinux.py", line 1519, in wrapper
raise AccessDenied(self.pid, self._name)
psutil.AccessDenied: psutil.AccessDenied (pid=371, name='bash')

Python Shell Script Running but Not running when calling it via crontab

Problem: I am trying to run a shell script which contains python script from Debian Linux env which is running properly but when I am calling it via crontab it is giving me an error below.
error
Traceback (most recent call last):
File "/home/samsunguk/env/lib/python3.5/site-packages/oauth2client/clientsecrets.py", line 121, in _loadfile
with open(filename, 'r') as fp:
FileNotFoundError: [Errno 2] No such file or directory: './client_secrets.json'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/samsunguk/env/lib/python3.5/site-packages/pydrive/auth.py", line 386, in LoadClientConfigFile
client_type, client_info = clientsecrets.loadfile(client_config_file)
File "/home/samsunguk/env/lib/python3.5/site-packages/oauth2client/clientsecrets.py", line 165, in loadfile
return _loadfile(filename)
File "/home/samsunguk/env/lib/python3.5/site-packages/oauth2client/clientsecrets.py", line 125, in _loadfile
exc.strerror, exc.errno)
oauth2client.clientsecrets.InvalidClientSecretsError: ('Error opening file', './client_secrets.json', 'No such file or directory', 2)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/samsunguk/segmentTrendsandTraits/segmentTrend.py", line 193, in <module>
extract_data(60, "csv_output_all_data_segments_BAAAM.csv", "output_data_segments_Last60days.csv", "output_data_segments_Last60days.xlsx")
File "/home/samsunguk/segmentTrendsandTraits/segmentTrend.py", line 185, in extract_data
gauth.LocalWebserverAuth()
File "/home/samsunguk/env/lib/python3.5/site-packages/pydrive/auth.py", line 113, in _decorated
self.GetFlow()
File "/home/samsunguk/env/lib/python3.5/site-packages/pydrive/auth.py", line 443, in GetFlow
self.LoadClientConfig()
File "/home/samsunguk/env/lib/python3.5/site-packages/pydrive/auth.py", line 366, in LoadClientConfig
self.LoadClientConfigFile()
File "/home/samsunguk/env/lib/python3.5/site-packages/pydrive/auth.py", line 388, in LoadClientConfigFile
raise InvalidConfigError('Invalid client secrets file %s' % error)
pydrive.settings.InvalidConfigError: Invalid client secrets file ('Error opening file', './client_secrets.json', 'No such file or directory', 2)
My python script has google authorization credentials.
Can anyone help me why I am getting this error?

python can't show my installed librery packages

devignesh#devignesh:~/soup$ pip list
Exception:
Traceback (most recent call last):
File "/usr/local/lib/python3.5/dist-packages/pip/_vendor/pkg_resources/__init__.py", line 2556, in version
return self._version
File "/usr/local/lib/python3.5/dist-packages/pip/_vendor/pkg_resources/__init__.py", line 2663, in __getattr__
raise AttributeError(attr)
AttributeError: _version
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/lib/python3.5/dist-packages/pip/_internal/basecommand.py", line 141, in main
status = self.run(options, args)
File "/usr/local/lib/python3.5/dist-packages/pip/_internal/commands/list.py", line 143, in run
self.output_package_listing(packages, options)
File "/usr/local/lib/python3.5/dist-packages/pip/_internal/commands/list.py", line 208, in output_package_listing
data, header = format_for_columns(packages, options)
File "/usr/local/lib/python3.5/dist-packages/pip/_internal/commands/list.py", line 274, in format_for_columns
row = [proj.project_name, proj.version]
File "/usr/local/lib/python3.5/dist-packages/pip/_vendor/pkg_resources/__init__.py", line 2561, in version
raise ValueError(tmpl % self.PKG_INFO, self)
ValueError: ("Missing 'Version:' header and/or METADATA file", Unknown [unknown version] (/home/devignesh/.local/lib/python3.5/site-packages))
devignesh#devignesh:~/soup$

Error using pip commands after 19.0.1 update

I just updated pip and some packages and now I get the following error when running just about any command like show or list (-V works):
Exception:
Traceback (most recent call last):
File "/Users/sterlingbutters/anaconda3/lib/python3.6/site-packages/pip/_vendor/pkg_resources/__init__.py", line 2897, in _dep_map
return self.__dep_map
File "/Users/sterlingbutters/anaconda3/lib/python3.6/site-packages/pip/_vendor/pkg_resources/__init__.py", line 2691, in __getattr__
raise AttributeError(attr)
AttributeError: _DistInfoDistribution__dep_map
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Users/sterlingbutters/anaconda3/lib/python3.6/site-packages/pip/_vendor/pkg_resources/__init__.py", line 2888, in _parsed_pkg_info
return self._pkg_info
File "/Users/sterlingbutters/anaconda3/lib/python3.6/site-packages/pip/_vendor/pkg_resources/__init__.py", line 2691, in __getattr__
raise AttributeError(attr)
AttributeError: _pkg_info
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Users/sterlingbutters/anaconda3/lib/python3.6/site-packages/pip/_internal/cli/base_command.py", line 176, in main
status = self.run(options, args)
File "/Users/sterlingbutters/anaconda3/lib/python3.6/site-packages/pip/_internal/commands/show.py", line 47, in run
results, list_files=options.files, verbose=options.verbose):
File "/Users/sterlingbutters/anaconda3/lib/python3.6/site-packages/pip/_internal/commands/show.py", line 137, in print_results
pkg.project_name for pkg in pkg_resources.working_set
File "/Users/sterlingbutters/anaconda3/lib/python3.6/site-packages/pip/_internal/commands/show.py", line 138, in <listcomp>
if name in [required.name for required in pkg.requires()]
File "/Users/sterlingbutters/anaconda3/lib/python3.6/site-packages/pip/_vendor/pkg_resources/__init__.py", line 2635, in requires
dm = self._dep_map
File "/Users/sterlingbutters/anaconda3/lib/python3.6/site-packages/pip/_vendor/pkg_resources/__init__.py", line 2899, in _dep_map
self.__dep_map = self._compute_dependencies()
File "/Users/sterlingbutters/anaconda3/lib/python3.6/site-packages/pip/_vendor/pkg_resources/__init__.py", line 2908, in _compute_dependencies
for req in self._parsed_pkg_info.get_all('Requires-Dist') or []:
File "/Users/sterlingbutters/anaconda3/lib/python3.6/site-packages/pip/_vendor/pkg_resources/__init__.py", line 2890, in _parsed_pkg_info
metadata = self.get_metadata(self.PKG_INFO)
File "/Users/sterlingbutters/anaconda3/lib/python3.6/site-packages/pip/_vendor/pkg_resources/__init__.py", line 1410, in get_metadata
value = self._get(self._fn(self.egg_info, name))
File "/Users/sterlingbutters/anaconda3/lib/python3.6/site-packages/pip/_vendor/pkg_resources/__init__.py", line 1522, in _get
with open(path, 'rb') as stream:
FileNotFoundError: [Errno 2] No such file or directory: '/Users/sterlingbutters/anaconda3/lib/python3.6/site-packages/-ytz-2018.5.dist-info/METADATA'
Is this just my configuration or is there a known bug, etc?
Any ideas on how to fix it? - I can't say I've ever had this problem before

Categories

Resources