When trying to access SECRET_KEY from env it shows none - python

This are my env variables
Trying to access variables form env of windows
OUTPUT :
None
None
enter image description here
AND WHEN I TRY ANOTHER METHOD TO GET DATA FROM ENV IT SHOWS
OUTPUT :
Traceback (most recent call last):
File ".\test.py", line 5, in <module>
SECRET_KEY = os.environ['SECRET_KEY']
File "C:\Users\Vivek\AppData\Local\Programs\Python\Python38\lib\os.py", line 673, in __getitem__
raise KeyError(key) from None
KeyError: 'SECRET_KEY'

Related

ChannelAttribution built-in function “markov_model_local_api” not working on sample codes

I am working on a channels attribution project in Python. I use the python library "ChannelAttribution". When I followed the instruction from the official documentation and tried to use the built-in function "markov_model_local_api", it kept throwing an error. Then I tried to run the sample codes from https://channelattribution.io/pdf/ChannelAttributionWhitePaper.pdf:
from ChannelAttribution import *
#Download data
Data = pd.read_csv("https://channelattribution.io/csv/Data.csv",sep=";")
#Generate token
generate_token(email="my_email", job="my_job", company="my_institution")
token = 'my_token'
#Train
res=markov_model_local_api(token, Data, var_path="path", var_conv="total_conversions",var_value="total_conversion_value", var_null="total_null", order=1, sep=">")
It throws these errors below:
Exception ignored in: <function Connection.__del__ at 0x7fba45595670>
Traceback (most recent call last):
File "/Users/li/opt/anaconda3/lib/python3.8/site-packages/pysftp/__init__.py", line 1013, in __del__
self.close()
File "/Users/li/opt/anaconda3/lib/python3.8/site-packages/pysftp/__init__.py", line 784, in close
if self._sftp_live:
AttributeError: 'Connection' object has no attribute '_sftp_live'
Traceback (most recent call last):
File "src/cypack/ChannelAttribution.pyx", line 1188, in ChannelAttribution.markov_model_local_api
File "src/cypack/ChannelAttribution.pyx", line 894, in ChannelAttribution.__f_initialize_connection
File "/Users/li/opt/anaconda3/lib/python3.8/site-packages/pysftp/__init__.py", line 132, in __init__
self._tconnect['hostkey'] = self._cnopts.get_hostkey(host)
File "/Users/li/opt/anaconda3/lib/python3.8/site-packages/pysftp/__init__.py", line 71, in get_hostkey
raise SSHException("No hostkey for host %s found." % host)
SSHException: No hostkey for host 13.58.174.83 found.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Users/li/Downloads/untitled0.py", line 18, in <module>
res=markov_model_local_api(token, Data, var_path="path", var_conv="total_conversions", var_value="total_conversion_value", var_null="total_null", order=1, sep=">")
File "src/cypack/ChannelAttribution.pyx", line 1248, in ChannelAttribution.markov_model_local_api
UnboundLocalError: local variable 'filename' referenced before assignment
How can I fix all errors and exceptions?

setup.cfg declaring console_scripts errors with "Entry points must be listed in groups"

I'm trying to configure setuptools to create a console entry point for my package, following the docs, and ending up with the following config:
[options.entry_points]
console_scripts =
hiplog = hiplog.scripts.hiplog:cli
But when I pip install -e . in my repository, pip raises the following error:
ERROR: Exception:
Traceback (most recent call last):
File "/home/taschan/.pyenv/versions/3.9.0/envs/hiplog/lib/python3.9/site-packages/pip/_vendor/pkg_resources/__init__.py", line 2857, in get_entry_map
ep_map = self._ep_map
File "/home/taschan/.pyenv/versions/3.9.0/envs/hiplog/lib/python3.9/site-packages/pip/_vendor/pkg_resources/__init__.py", line 2815, in __getattr__
raise AttributeError(attr)
AttributeError: _ep_map
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/taschan/.pyenv/versions/3.9.0/envs/hiplog/lib/python3.9/site-packages/pip/_internal/cli/base_command.py", line 228, in _main
status = self.run(options, args)
File "/home/taschan/.pyenv/versions/3.9.0/envs/hiplog/lib/python3.9/site-packages/pip/_internal/cli/req_command.py", line 182, in wrapper
return func(self, options, args)
File "/home/taschan/.pyenv/versions/3.9.0/envs/hiplog/lib/python3.9/site-packages/pip/_internal/commands/install.py", line 397, in run
installed = install_given_reqs(
File "/home/taschan/.pyenv/versions/3.9.0/envs/hiplog/lib/python3.9/site-packages/pip/_internal/req/__init__.py", line 75, in install_given_reqs
uninstalled_pathset = requirement.uninstall(
File "/home/taschan/.pyenv/versions/3.9.0/envs/hiplog/lib/python3.9/site-packages/pip/_internal/req/req_install.py", line 685, in uninstall
uninstalled_pathset = UninstallPathSet.from_dist(dist)
File "/home/taschan/.pyenv/versions/3.9.0/envs/hiplog/lib/python3.9/site-packages/pip/_internal/req/req_uninstall.py", line 571, in from_dist
console_scripts = dist.get_entry_map(group='console_scripts')
File "/home/taschan/.pyenv/versions/3.9.0/envs/hiplog/lib/python3.9/site-packages/pip/_vendor/pkg_resources/__init__.py", line 2859, in get_entry_map
ep_map = self._ep_map = EntryPoint.parse_map(
File "/home/taschan/.pyenv/versions/3.9.0/envs/hiplog/lib/python3.9/site-packages/pip/_vendor/pkg_resources/__init__.py", line 2531, in parse_map
raise ValueError("Entry points must be listed in groups")
ValueError: Entry points must be listed in groups
What am I doing wrong?
I ran into this same symptom, and the root cause turned out to be a botched pip install -e . from a previous run. Deleting the projectname.egg-info directory did the trick.

twitterImgBot stops working after some hours

I'm trying to get this, https://github.com/joaquinlpereyra/twitterImgBot, to work
and it works and it seems ok.
But after some hours, it stops working and this error comes up:
*python3 twitterbot.py
Traceback (most recent call last):
File "/home/user/.local/lib/python3.7/site-packages/tweepy/binder.py", line 118, in build_path
value = quote(self.session.params[name])
KeyError: 'id'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "twitterbot.py", line 209, in <module>
main()
File "twitterbot.py", line 200, in main
orders()
File "twitterbot.py", line 118, in orders
timeline.delete_tweet_by_id(tweet.in_reply_to_status_id, api)
File "/home/user/Skrivebord/twitterboot/lo/bot/timeline.py", line 12, in delete_tweet_by_id
api.destroy_status(id_to_delete)
File "/home/user/.local/lib/python3.7/site-packages/tweepy/binder.py", line 245, in _call
method = APIMethod(args, kwargs)
File "/home/user/.local/lib/python3.7/site-packages/tweepy/binder.py", line 71, in __init__
self.build_path()
File "/home/user/.local/lib/python3.7/site-packages/tweepy/binder.py", line 120, in build_path
raise TweepError('No parameter value found for path variable: %s' % name)
tweepy.error.TweepError: No parameter value found for path variable: id*
It seems like the Python has some problem because if I make a new install on a another PC it works for some hours and then stops.
Strange.
This is likely because tweet is not in reply to a status, so has an in_reply_to_status_id attribute that's None, so API.destroy_status is called with an id of None.

Dash traceback not leading to any line in my code

I am working on my first Dash app. I am getting the following error:
"Cannot set a frame with no defined index "
The issue is that the traceback doesn’t lead to any line in my code. It only goes through installed libraries:
Traceback (most recent call last):
File "C:\Users\LIAG8802\Documents\Procurement_analytics\venv\lib\site-packages\pandas\core\frame.py", line 3540, in _ensure_valid_index
value = Series(value)
File "C:\Users\LIAG8802\Documents\Procurement_analytics\venv\lib\site-packages\pandas\core\series.py", line 316, in __init__
data = SingleBlockManager(data, index, fastpath=True)
File "C:\Users\LIAG8802\Documents\Procurement_analytics\venv\lib\site-packages\pandas\core\internals\managers.py", line 1516, in __init__
block = make_block(block, placement=slice(0, len(axis)), ndim=1)
File "C:\Users\LIAG8802\Documents\Procurement_analytics\venv\lib\site-packages\pandas\core\internals\blocks.py", line 3284, in make_block
return klass(values, ndim=ndim, placement=placement)
File "C:\Users\LIAG8802\Documents\Procurement_analytics\venv\lib\site-packages\pandas\core\internals\blocks.py", line 2792, in __init__
super().__init__(values, ndim=ndim, placement=placement)
File "C:\Users\LIAG8802\Documents\Procurement_analytics\venv\lib\site-packages\pandas\core\internals\blocks.py", line 128, in __init__
"{mgr}".format(val=len(self.values), mgr=len(self.mgr_locs))
ValueError: Wrong number of items passed 3, placement implies 0
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\LIAG8802\Documents\Procurement_analytics\venv\lib\site-packages\pandas\core\frame.py", line 3543, in _ensure_valid_index
"Cannot set a frame with no defined index "
ValueError: Cannot set a frame with no defined index and a value that cannot be converted to a Series
How can I know which line in my code is causing the error? Note that I found out what the problem was but I want to know how I could have traced it more easily.
EDIT: note that I cannot track the issue putting prints at several lines since the error pops out in the dash debug console, not in the anaconda console which does not crash

D-Bus - 'ServiceUnknown' exception encountered while calling a remote procedure

I'm trying to call the remote procedure DisplayFolderAndSelect() of Thunar file manager from my own program:
import dbus
bus = dbus.SessionBus()
obj = bus.get_object('org.xfce.Thunar', '/org/xfce/FileManager')
iface = dbus.Interface(obj, 'org.xfce.FileManager')
_thunar_display_folder_and_select = iface.get_dbus_method('DisplayFolderAndSelect')
_thunar_display_folder_and_select('~/Downloads/', 'doc.pdf', '', '')
However I've encountered the following exception at runtime:
Traceback (most recent call last): File "", line 1, in
File "/usr/lib/python2.7/dist-packages/dbus/proxies.py",
line 70, in call
return self._proxy_method(*args, **keywords) File "/usr/lib/python2.7/dist-packages/dbus/proxies.py", line 145, in
call
**keywords) File "/usr/lib/python2.7/dist-packages/dbus/connection.py", line 651, in
call_blocking
message, timeout) dbus.exceptions.DBusException: org.freedesktop.DBus.Error.ServiceUnknown: The name :1.576 was not
provided by any .service files
I'm unable to understand what does this exception mean. And what's the cause behind the exception.
Any thoughts?
I think it is an OS-related issue, restarting D-Bus service solved the problem

Categories