"OSError: Starting path not found" when importing spotifycharts - python-3.x

I get the following error when importing spotifycharts:
OSError: Starting path not found
When I do pip freeze it's listed.
Full error:
OSError Traceback (most recent call last)
/var/folders/fm/ck9x_7l55y93t7gkxl93g_q40000gn/T/ipykernel_57786/3799758561.py in <module>
1 import environs
----> 2 import spotifycharts as sc
/opt/anaconda3/envs/python39/lib/python3.9/site-packages/spotifycharts/__init__.py in <module>
9 from tqdm import auto
10
---> 11 from spotifycharts import classes
12 from spotifycharts import settings
13 from spotifycharts import exceptions
/opt/anaconda3/envs/python39/lib/python3.9/site-packages/spotifycharts/classes.py in <module>
10
11 import spotifycharts as sc
---> 12 from spotifycharts import settings
13 from spotifycharts import exceptions
14 from spotifycharts.logging import logger
/opt/anaconda3/envs/python39/lib/python3.9/site-packages/spotifycharts/settings.py in <module>
1 import environs
2 configuration = environs.Env()
----> 3 configuration.read_env('spotifycharts/configuration.env')
4
5
/opt/anaconda3/envs/python39/lib/python3.9/site-packages/environs/__init__.py in read_env(path, recurse, verbose, override)
413 if not start_dir: # Only a filename was given
414 start_dir = os.getcwd()
--> 415 for dirname in _walk_to_root(start_dir):
416 check_path = Path(dirname) / env_name
417 if check_path.exists():
/opt/anaconda3/envs/python39/lib/python3.9/site-packages/dotenv/main.py in _walk_to_root(path)
244 """
245 if not os.path.exists(path):
--> 246 raise IOError('Starting path not found')
247
248 if os.path.isfile(path):
OSError: Starting path not found
How do I solve this?

Was able to find a workaround.
Open the settings.py file located in /opt/anaconda3/envs/python39/lib/python3.9/site-packages/spotifycharts/ in above case.
Add the full path to the read_env() method
Change
configuration.read_env('spotifycharts/configuration.env')
to
configuration.read_env('/opt/anaconda3/envs/python39/lib/python3.9/site-packages/spotifycharts/configuration.env')

Related

Error importing LayoutLMv2ForTokenClassification from HuggingFace

I am trying to run this demo notebook on colab and I am getting the following pytorch error when importing LayoutLMv2ForTokenClassification:
from transformers import LayoutLMv2ForTokenClassification
Error:
ModuleNotFoundError Traceback (most recent call last)
~\PycharmProjects\playground\camelot\camelotenv\lib\site-packages\transformers\utils\import_utils.py in _get_module(self, module_name)
1029 try:
-> 1030 return importlib.import_module("." + module_name, self.__name__)
1031 except Exception as e:
~\AppData\Local\Programs\Python\Python39\lib\importlib\__init__.py in import_module(name, package)
126 level += 1
--> 127 return _bootstrap._gcd_import(name[level:], package, level)
128
~\AppData\Local\Programs\Python\Python39\lib\importlib\_bootstrap.py in _gcd_import(name, package, level)
~\AppData\Local\Programs\Python\Python39\lib\importlib\_bootstrap.py in _find_and_load(name, import_)
~\AppData\Local\Programs\Python\Python39\lib\importlib\_bootstrap.py in _find_and_load_unlocked(name, import_)
~\AppData\Local\Programs\Python\Python39\lib\importlib\_bootstrap.py in _load_unlocked(spec)
~\AppData\Local\Programs\Python\Python39\lib\importlib\_bootstrap_external.py in exec_module(self, module)
~\AppData\Local\Programs\Python\Python39\lib\importlib\_bootstrap.py in _call_with_frames_removed(f, *args, **kwds)
~\PycharmProjects\playground\camelot\camelotenv\lib\site-packages\transformers\models\layoutlmv2\modeling_layoutlmv2.py in <module>
48 import detectron2
---> 49 from detectron2.modeling import META_ARCH_REGISTRY
50
~\PycharmProjects\playground\camelot\camelotenv\lib\site-packages\detectron2\modeling\__init__.py in <module>
19 )
---> 20 from .meta_arch import (
21 META_ARCH_REGISTRY,
~\PycharmProjects\playground\camelot\camelotenv\lib\site-packages\detectron2\modeling\meta_arch\__init__.py in <module>
5
----> 6 from .panoptic_fpn import PanopticFPN
7
~\PycharmProjects\playground\camelot\camelotenv\lib\site-packages\detectron2\modeling\meta_arch\panoptic_fpn.py in <module>
13 from .build import META_ARCH_REGISTRY
---> 14 from .rcnn import GeneralizedRCNN
15 from .semantic_seg import build_sem_seg_head
~\PycharmProjects\playground\camelot\camelotenv\lib\site-packages\detectron2\modeling\meta_arch\rcnn.py in <module>
17 from ..proposal_generator import build_proposal_generator
---> 18 from ..roi_heads import build_roi_heads
19 from .build import META_ARCH_REGISTRY
~\PycharmProjects\playground\camelot\camelotenv\lib\site-packages\detectron2\modeling\roi_heads\__init__.py in <module>
14 )
---> 15 from .roi_heads import (
16 ROI_HEADS_REGISTRY,
~\PycharmProjects\playground\camelot\camelotenv\lib\site-packages\detectron2\modeling\roi_heads\roi_heads.py in <module>
16 from ..matcher import Matcher
---> 17 from ..poolers import ROIPooler
18 from ..proposal_generator.proposal_utils import add_ground_truth_to_proposals
~\PycharmProjects\playground\camelot\camelotenv\lib\site-packages\detectron2\modeling\poolers.py in <module>
9 from detectron2.structures import Boxes
---> 10 from detectron2.utils.tracing import assert_fx_safe
11
~\PycharmProjects\playground\camelot\camelotenv\lib\site-packages\detectron2\utils\tracing.py in <module>
3 import torch
----> 4 from torch.fx._symbolic_trace import _orig_module_call
5 from torch.fx._symbolic_trace import is_fx_tracing as is_fx_tracing_current
ModuleNotFoundError: No module named 'torch.fx._symbolic_trace'
The above exception was the direct cause of the following exception:
RuntimeError Traceback (most recent call last)
<ipython-input-36-b5a73c6d310a> in <module>
4 device_ids = [0,1]
5
----> 6 from transformers import LayoutLMv2ForTokenClassification, TrainingArguments, Trainer
7 from datasets import load_metric
8 import numpy as np
~\AppData\Local\Programs\Python\Python39\lib\importlib\_bootstrap.py in _handle_fromlist(module, fromlist, import_, recursive)
~\PycharmProjects\playground\camelot\camelotenv\lib\site-packages\transformers\utils\import_utils.py in __getattr__(self, name)
1019 elif name in self._class_to_module.keys():
1020 module = self._get_module(self._class_to_module[name])
-> 1021 value = getattr(module, name)
1022 else:
1023 raise AttributeError(f"module {self.__name__} has no attribute {name}")
~\PycharmProjects\playground\camelot\camelotenv\lib\site-packages\transformers\utils\import_utils.py in __getattr__(self, name)
1018 value = self._get_module(name)
1019 elif name in self._class_to_module.keys():
-> 1020 module = self._get_module(self._class_to_module[name])
1021 value = getattr(module, name)
1022 else:
~\PycharmProjects\playground\camelot\camelotenv\lib\site-packages\transformers\utils\import_utils.py in _get_module(self, module_name)
1030 return importlib.import_module("." + module_name, self.__name__)
1031 except Exception as e:
-> 1032 raise RuntimeError(
1033 f"Failed to import {self.__name__}.{module_name} because of the following error (look up to see its"
1034 f" traceback):\n{e}"
RuntimeError: Failed to import transformers.models.layoutlmv2.modeling_layoutlmv2 because of the following error (look up to see its traceback):
No module named 'torch.fx._symbolic_trace'
Can anyone please help?
Thanks!
This is issue from importing torch.fix flag check for symbolic trace and new commit error of detectron (use 5aeb252b194b93dc2879b4ac34bc51a31b5aee13 this checkout and install )
for temporary work
or clone pytorch with new commit

Trouble importing modules into ipython

On a freshly installed Windows 10 machine, I installed the newest 64bit version of anaconda. Now when I try importing modules into ipython, I get errors. Some sample errors are reproduced below.
I am new to Python and Programming, so would appreciate a bit of help. This is a brand new Lenovo laptop, so there's no scope for any Python version conflict etc. (since nothing was installed on it earlier).
In [1]: import sklearn
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-1-b7c74cbf5af0> in <module>
----> 1 import sklearn
C:\Software\anaconda3\lib\site-packages\sklearn\__init__.py in <module>
74 else:
75 from . import __check_build
---> 76 from .base import clone
77 from .utils._show_versions import show_versions
78
C:\Software\anaconda3\lib\site-packages\sklearn\base.py in <module>
11 import re
12
---> 13 import numpy as np
14
15 from . import __version__
C:\Software\anaconda3\lib\site-packages\numpy\__init__.py in <module>
138
139 # Allow distributors to run custom init code
--> 140 from . import _distributor_init
141
142 from . import core
C:\Software\anaconda3\lib\site-packages\numpy\_distributor_init.py in <module>
32
33 with RTLD_for_MKL():
---> 34 from . import _mklinit
35
36 del RTLD_for_MKL
ImportError: DLL load failed: The specified module could not be found.
In [2]: import matplotlib.pyplot as plt
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-2-a0d2faabd9e9> in <module>
----> 1 import matplotlib.pyplot as plt
C:\Software\anaconda3\lib\site-packages\matplotlib\__init__.py in <module>
136 # cbook must import matplotlib only within function
137 # definitions, so it is safe to import from it here.
--> 138 from . import cbook, rcsetup
139 from matplotlib.cbook import (
140 MatplotlibDeprecationWarning, dedent, get_label, sanitize_sequence)
C:\Software\anaconda3\lib\site-packages\matplotlib\cbook\__init__.py in <module>
29 from weakref import WeakMethod
30
---> 31 import numpy as np
32
33 import matplotlib
C:\Software\anaconda3\lib\site-packages\numpy\__init__.py in <module>
138
139 # Allow distributors to run custom init code
--> 140 from . import _distributor_init
141
142 from . import core
C:\Software\anaconda3\lib\site-packages\numpy\_distributor_init.py in <module>
32
33 with RTLD_for_MKL():
---> 34 from . import _mklinit
35
36 del RTLD_for_MKL
ImportError: DLL load failed: The specified module could not be found.
In [3]: import pystan
---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-3-ca8618bb8e4a> in <module>
----> 1 import pystan
ModuleNotFoundError: No module named 'pystan'
In [4]:
After a lot of google searching, I found a few sites that touch upon some closely related issues (ex. https://github.com/stan-dev/pystan/issues/520). It so happens that one needs to add some anaconda directroties to the Windows path. I added anaconda/Library/bin, anaconda/Scripts to the path. Now everything is working as expected.

How can I eliminate "UnpicklingError: invalid load key, '\x00'" in win32com?

I'm using the latest version of win32com on Windows 7 and Python 3.6. import win32com.client working fine until recently. I'm now getting an UnpicklingError exception.
I've tried reinstalling the latest version globally as well as in a separate virtual environment.
In [1]: import win32com.client
---------------------------------------------------------------------------
UnpicklingError Traceback (most recent call last)
<ipython-input-1-acfbed532f32> in <module>()
----> 1 import win32com.client
C:\ProgramData\Anaconda3\lib\site-packages\win32com\client\__init__.py in <module>()
9 import pythoncom
10 from . import dynamic
---> 11 from . import gencache
12 import sys
13 import pywintypes
C:\ProgramData\Anaconda3\lib\site-packages\win32com\client\gencache.py in <module>()
658
659 # Boot up
--> 660 __init__()
661
662 def usage():
C:\ProgramData\Anaconda3\lib\site-packages\win32com\client\gencache.py in __init__()
58 # Initialize the module. Called once explicitly at module import below
59 try:
---> 60 _LoadDicts()
61 except IOError:
62 Rebuild()
C:\ProgramData\Anaconda3\lib\site-packages\win32com\client\gencache.py in _LoadDicts()
111 try:
112 p = pickle.Unpickler(f)
--> 113 version = p.load()
114 global clsidToTypelib
115 clsidToTypelib = p.load()
UnpicklingError: invalid load key, '\x00'.

How do you run tensorflow on colaboratory?

I'm trying to use Google's Colaboratory. The first line of output was hopeful.
Using TensorFlow backend.
But then I got this error message.
ImportError: libcublas.so.9.0: cannot open shared object file: No such file or directory
That error apparently triggered another error. (Sorry for the long stack trace, but the error message itself suggested including it when asking for help.)
During handling of the above exception, another exception occurred:
ImportError Traceback (most recent call last)
<ipython-input-6-0b846698ae4a> in <module>()
2 import numpy as np
3 import matplotlib.pylab as plt
----> 4 from keras.models import Sequential
5 from keras.layers import Dense, InputLayer
6
/usr/local/lib/python3.6/dist-packages/keras/__init__.py in <module>()
1 from __future__ import absolute_import
2
----> 3 from . import utils
4 from . import activations
5 from . import applications
/usr/local/lib/python3.6/dist-packages/keras/utils/__init__.py in <module>()
4 from . import data_utils
5 from . import io_utils
----> 6 from . import conv_utils
7
8 # Globally-importable utils.
/usr/local/lib/python3.6/dist-packages/keras/utils/conv_utils.py in <module>()
7 from six.moves import range
8 import numpy as np
----> 9 from .. import backend as K
10
11
/usr/local/lib/python3.6/dist-packages/keras/backend/__init__.py in <module>()
82 elif _BACKEND == 'tensorflow':
83 sys.stderr.write('Using TensorFlow backend.\n')
---> 84 from .tensorflow_backend import *
85 else:
86 raise ValueError('Unknown backend: ' + str(_BACKEND))
/usr/local/lib/python3.6/dist-packages/keras/backend/tensorflow_backend.py in <module>()
3 from __future__ import print_function
4
----> 5 import tensorflow as tf
6 from tensorflow.python.training import moving_averages
7 from tensorflow.python.ops import tensor_array_ops
/usr/local/lib/python3.6/dist-packages/tensorflow/__init__.py in <module>()
22
23 # pylint: disable=g-bad-import-order
---> 24 from tensorflow.python import pywrap_tensorflow # pylint: disable=unused-import
25 # pylint: disable=wildcard-import
26 from tensorflow.tools.api.generator.api import * # pylint: disable=redefined-builtin
/usr/local/lib/python3.6/dist-packages/tensorflow/python/__init__.py in <module>()
47 import numpy as np
48
---> 49 from tensorflow.python import pywrap_tensorflow
50
51 # Protocol buffers
/usr/local/lib/python3.6/dist-packages/tensorflow/python/pywrap_tensorflow.py in <module>()
72 for some common reasons and solutions. Include the entire stack trace
73 above this error message when asking for help.""" % traceback.format_exc()
---> 74 raise ImportError(msg)
75
76 # pylint: enable=wildcard-import,g-import-not-at-top,unused-import,line-too-long
ImportError: Traceback (most recent call last):
File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/pywrap_tensorflow.py", line 58, in <module>
from tensorflow.python.pywrap_tensorflow_internal import *
File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 28, in <module>
_pywrap_tensorflow_internal = swig_import_helper()
File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 24, in swig_import_helper
_mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname, description)
File "/usr/lib/python3.6/imp.py", line 243, in load_module
return load_dynamic(name, filename, file)
File "/usr/lib/python3.6/imp.py", line 343, in load_dynamic
return _load(spec)
ImportError: libcublas.so.9.0: cannot open shared object file: No such file or directory
Failed to load the native TensorFlow runtime.
See https://www.tensorflow.org/install/install_sources#common_installation_problems
for some common reasons and solutions. Include the entire stack trace
above this error message when asking for help.
Below that was a suggestion to consult https://www.tensorflow.org/install/install_sources#common_installation_problems.
But that page is about installing TensorFlow from source. I'm not trying to install from source. I just want a runnable version that I can call.
Any suggestions would be appreciated.
Thanks.

boxsdk demo/auth.py fails on from boxsdk import OAuth2

Running on python 3.6 (anaconda)
Tried to run authenticate() within boxsdk: demo/auth.py and get error on import.
Looks like error is happening in /anaconda/lib/python3.6/site-packages/boxsdk/object/events.py....
class EventsStreamType(with_metaclass(ExtendableEnumMeta, TextEnum)):
I did look thru other posts but don't see solution
python - Fix 'new enumerations must be created as' - Stack Overflow
boxsdk 1.x does not import in python 3.6.0 · Issue #195 · box/box ...
ERROR
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-33-e86018378e6f> in <module>()
9 from wsgiref.simple_server import WSGIServer, WSGIRequestHandler, make_server
10
---> 11 from boxsdk import OAuth2
12
13
/anaconda/lib/python3.6/site-packages/boxsdk/__init__.py in <module>()
4
5 from .auth import JWTAuth, OAuth2
----> 6 from .client import * # pylint:disable=wildcard-import,redefined-builtin
7 from .object import * # pylint:disable=wildcard-import,redefined-builtin
8 from .version import __version__
/anaconda/lib/python3.6/site-packages/boxsdk/client/__init__.py in <module>()
3 from __future__ import unicode_literals, absolute_import
4
----> 5 from .client import Client
6 from .developer_token_client import DeveloperTokenClient
7 from .development_client import DevelopmentClient
/anaconda/lib/python3.6/site-packages/boxsdk/client/client.py in <module>()
10 from ..object.folder import Folder
11 from ..object.search import Search
---> 12 from ..object.events import Events
13 from ..object.file import File
14 from ..object.group import Group
/anaconda/lib/python3.6/site-packages/boxsdk/object/events.py in <module>()
13
14 # pylint:disable=too-many-ancestors
---> 15 class EventsStreamType(with_metaclass(ExtendableEnumMeta, TextEnum)):
16 """An enum of all possible values of the `stream_type` parameter for user events.
17
/anaconda/lib/python3.6/enum.py in __prepare__(metacls, cls, bases)
117 enum_dict = _EnumDict()
118 # inherit previous flags and _generate_next_value_ function
--> 119 member_type, first_enum = metacls._get_mixins_(bases)
120 if first_enum is not None:
121 enum_dict['_generate_next_value_'] = getattr(first_enum, '_generate_next_value_', None)
/anaconda/lib/python3.6/enum.py in _get_mixins_(bases)
437 # base is now the last base in bases
438 if not issubclass(base, Enum):
--> 439 raise TypeError("new enumerations must be created as "
440 "`ClassName([mixin_type,] enum_type)`")
441
TypeError: new enumerations must be created as `ClassName([mixin_type,] enum_type)`

Resources