I have been trying to connect to my local neo4j server using py2neo v3 and neo4j version 3.4.1.
The commands I used are:-
from py2neo import Graph, Node, Relationship
graphURL='http://localhost:7474/db/data/'
graphUser = "neo4j"
graphPassphrase = "XXXX"
graph=Graph(graphURL, user=graphUser, password=graphPassphrase)
I receive the following errors on trying to use this code.
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-20-ab3844caf22c> in <module>()
3 graphPassphrase = "XXXX"
4
----> 5 graph=Graph(graphURL, user=graphUser, password=graphPassphrase)
~\Anaconda3\lib\site-packages\py2neo\graph.py in __new__(cls, *uris, **settings)
333 def __new__(cls, *uris, **settings):
334 database = settings.pop("database", "data")
--> 335 graph_service = GraphService(*uris, **settings)
336 address = graph_service.address
337 if database in graph_service:
~\Anaconda3\lib\site-packages\py2neo\graph.py in __new__(cls, *uris, **settings)
77 from py2neo.addressing import register_graph_service, get_graph_service_auth
78 from py2neo.http import register_http_driver
---> 79 from neo4j.v1 import GraphDatabase
80 register_http_driver()
81 address = register_graph_service(*uris, **settings)
~\Anaconda3\lib\site-packages\neo4j\v1\__init__.py in <module>()
20
21 from .api import *
---> 22 from .bolt import *
23 from .security import *
24 from .types import *
~\Anaconda3\lib\site-packages\neo4j\v1\bolt.py in <module>()
30 from .security import SecurityPlan, Unauthorized
31 from .summary import ResultSummary
---> 32 from .types import Record
33
34
~\Anaconda3\lib\site-packages\neo4j\v1\types\__init__.py in <module>()
31 from operator import xor as xor_operator
32
---> 33 from neo4j.packstream import Structure
34 from neo4j.compat import map_type, string, integer, ustr
35
~\Anaconda3\lib\site-packages\neo4j\packstream\__init__.py in <module>()
20
21
---> 22 from neo4j.util import import_best as _import_best
23
24 from .structure import Structure
ImportError: cannot import name 'import_best'
I have tried using the handbook https://py2neo.org/v3/database.html?highlight=relation for v3 but it was of no use for my problem. Could you please help me with this issue.
The driver support the BOLT and HTTP proctole, but it seems here that you want to use the HTTP one, and the driver is trying to instantiate the BOLT ...
I recommend you to use BOLT, so your code should be :
from py2neo import Graph, Node, Relationship
graphHost='localhost'
graphUser = "neo4j"
graphPassphrase = "XXXX"
graph=Graph(bolt=true, host=graphHost, user=graphUser, password=graphPassphrase)
If you really want to use the http :
graph=Graph(bolt=false, host=graphHost, user=graphUser, password=graphPassphrase)
Related
I installed pytorch-lightning using pip, and I'm running on Mac.
I tried:
! pip install pytorch-lightning --upgrade
! pip install pytorch-lightning-bolts
(finished successfully)
and then:
import pytorch_lightning as pl
and what I get is:
--
-------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-3-f3b4217dcea1> in <module>
7 from torchvision.datasets import MNIST
8 from torchvision import transforms
----> 9 import pytorch_lightning as pl
10 from pytorch_lightning.metrics.functional import accuracy
11 tmpdir = os.getcwd()
/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/pytorch_lightning/__init__.py in <module>
60 # We are not importing the rest of the lightning during the build process, as it may not be compiled yet
61 else:
---> 62 from pytorch_lightning import metrics
63 from pytorch_lightning.callbacks import Callback
64 from pytorch_lightning.core import LightningDataModule, LightningModule
/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/pytorch_lightning/metrics/__init__.py in <module>
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
---> 14 from pytorch_lightning.metrics.classification import ( # noqa: F401
15 Accuracy,
16 AUC,
/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/pytorch_lightning/metrics/classification/__init__.py in <module>
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
---> 14 from pytorch_lightning.metrics.classification.accuracy import Accuracy # noqa: F401
15 from pytorch_lightning.metrics.classification.auc import AUC # noqa: F401
16 from pytorch_lightning.metrics.classification.auroc import AUROC # noqa: F401
/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/pytorch_lightning/metrics/classification/accuracy.py in <module>
16 import torch
17
---> 18 from pytorch_lightning.metrics.functional.accuracy import _accuracy_compute, _accuracy_update
19 from pytorch_lightning.metrics.metric import Metric
20
/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/pytorch_lightning/metrics/functional/__init__.py in <module>
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
---> 14 from pytorch_lightning.metrics.functional.accuracy import accuracy # noqa: F401
15 from pytorch_lightning.metrics.functional.auc import auc # noqa: F401
16 from pytorch_lightning.metrics.functional.auroc import auroc # noqa: F401
/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/pytorch_lightning/metrics/functional/accuracy.py in <module>
16 import torch
17
---> 18 from pytorch_lightning.metrics.classification.helpers import _input_format_classification, DataType
19
20
/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/pytorch_lightning/metrics/classification/helpers.py in <module>
17 import torch
18
---> 19 from pytorch_lightning.metrics.utils import select_topk, to_onehot
20 from pytorch_lightning.utilities import LightningEnum
21
/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/pytorch_lightning/metrics/utils.py in <module>
16 import torch
17
---> 18 from pytorch_lightning.utilities import rank_zero_warn
19
20 METRIC_EPS = 1e-6
/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/pytorch_lightning/utilities/__init__.py in <module>
16 import numpy
17
---> 18 from pytorch_lightning.utilities.apply_func import move_data_to_device # noqa: F401
19 from pytorch_lightning.utilities.distributed import ( # noqa: F401
20 AllGatherGrad,
/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/pytorch_lightning/utilities/apply_func.py in <module>
23
24 from pytorch_lightning.utilities.exceptions import MisconfigurationException
---> 25 from pytorch_lightning.utilities.imports import _TORCHTEXT_AVAILABLE
26
27 if _TORCHTEXT_AVAILABLE:
/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/pytorch_lightning/utilities/imports.py in <module>
54 _TORCH_GREATER_EQUAL_1_7 = _compare_version("torch", operator.ge, "1.7.0")
55 _TORCH_QUANTIZE_AVAILABLE = bool([eg for eg in torch.backends.quantized.supported_engines if eg != 'none'])
---> 56 _APEX_AVAILABLE = _module_available("apex.amp")
57 _BOLTS_AVAILABLE = _module_available('pl_bolts')
58 _DEEPSPEED_AVAILABLE = not _IS_WINDOWS and _module_available('deepspeed')
/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/pytorch_lightning/utilities/imports.py in _module_available(module_path)
32 """
33 try:
---> 34 return find_spec(module_path) is not None
35 except AttributeError:
36 # Python 3.6
/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/importlib/util.py in find_spec(name, package)
92 parent_name = fullname.rpartition('.')[0]
93 if parent_name:
---> 94 parent = __import__(parent_name, fromlist=['__path__'])
95 try:
96 parent_path = parent.__path__
/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/apex/__init__.py in <module>
11 ISessionFactory)
12 from pyramid.security import NO_PERMISSION_REQUIRED
---> 13 from pyramid.session import UnencryptedCookieSessionFactoryConfig
14 from pyramid.settings import asbool
15
ImportError: cannot import name 'UnencryptedCookieSessionFactoryConfig' from 'pyramid.session' (unknown location
I guess this is an outdated issue as we have cut out TorchMetrics to a standalone package. Please, check out the latest PytorchLightning.
Try installing it from the GitHub repository first before importing it in the notebook.
Run the following command in the Notebook:
!pip install git+https://github.com/PyTorchLightning/pytorch-lightning
I've been trying to run this TensorFlow tutorial on my computer, but while running the following code I've been getting the error from the title:
import os
import shutil
import tensorflow as tf
import tensorflow_hub as hub
import tensorflow_text as text
from official.nlp import optimization # to create AdamW optmizer
import matplotlib.pyplot as plt
tf.get_logger().setLevel('ERROR')
os.environ['TF_FORCE_GPU_ALLOW_GROWTH'] = 'true'
This is the entire error traceback. While running it in the tutorial's Collab notebook there doesn't seem any problem whatsoever.
AttributeErrorTraceback (most recent call last)
<ipython-input-7-3afaa91eeb1f> in <module>
3
4 import tensorflow as tf
----> 5 import tensorflow_hub as hub
6 import tensorflow_text as text
7 from official.nlp import optimization # to create AdamW optmizer
/usr/local/lib/python3.6/dist-packages/tensorflow_hub/__init__.py in <module>
86
87
---> 88 from tensorflow_hub.estimator import LatestModuleExporter
89 from tensorflow_hub.estimator import register_module_for_export
90 from tensorflow_hub.feature_column import image_embedding_column
/usr/local/lib/python3.6/dist-packages/tensorflow_hub/estimator.py in <module>
60
61
---> 62 class LatestModuleExporter(tf.compat.v1.estimator.Exporter):
63 """Regularly exports registered modules into timestamped directories.
64
/usr/local/lib/python3.6/dist-packages/tensorflow/python/util/lazy_loader.py in __getattr__(self, item)
60
61 def __getattr__(self, item):
---> 62 module = self._load()
63 return getattr(module, item)
64
/usr/local/lib/python3.6/dist-packages/tensorflow/python/util/lazy_loader.py in _load(self)
43 """Load the module and insert it into the parent's globals."""
44 # Import the target module and insert it into the parent's namespace
---> 45 module = importlib.import_module(self.__name__)
46 self._parent_module_globals[self._local_name] = module
47
/usr/lib/python3.6/importlib/__init__.py in import_module(name, package)
124 break
125 level += 1
--> 126 return _bootstrap._gcd_import(name[level:], package, level)
127
128
/usr/local/lib/python3.6/dist-packages/tensorflow_estimator/python/estimator/api/_v1/estimator/__init__.py in <module>
8 import sys as _sys
9
---> 10 from tensorflow_estimator.python.estimator.api._v1.estimator import experimental
11 from tensorflow_estimator.python.estimator.api._v1.estimator import export
12 from tensorflow_estimator.python.estimator.api._v1.estimator import inputs
/usr/local/lib/python3.6/dist-packages/tensorflow_estimator/python/estimator/api/_v1/estimator/experimental/__init__.py in <module>
8 import sys as _sys
9
---> 10 from tensorflow_estimator.python.estimator.canned.dnn import dnn_logit_fn_builder
11 from tensorflow_estimator.python.estimator.canned.kmeans import KMeansClustering as KMeans
12 from tensorflow_estimator.python.estimator.canned.linear import LinearSDCA
/usr/local/lib/python3.6/dist-packages/tensorflow_estimator/python/estimator/canned/dnn.py in <module>
29 from tensorflow.python.keras.utils import losses_utils
30 from tensorflow.python.util.tf_export import estimator_export
---> 31 from tensorflow_estimator.python.estimator import estimator
32 from tensorflow_estimator.python.estimator.canned import head as head_lib
33 from tensorflow_estimator.python.estimator.canned import optimizers
/usr/local/lib/python3.6/dist-packages/tensorflow_estimator/python/estimator/estimator.py in <module>
50 from tensorflow.python.util.tf_export import estimator_export
51 from tensorflow_estimator.python.estimator import model_fn as model_fn_lib
---> 52 from tensorflow_estimator.python.estimator import run_config
53 from tensorflow_estimator.python.estimator import util as estimator_util
54 from tensorflow_estimator.python.estimator.export import export_lib
/usr/local/lib/python3.6/dist-packages/tensorflow_estimator/python/estimator/run_config.py in <module>
28 from tensorflow.core.protobuf import rewriter_config_pb2
29 from tensorflow.python.distribute import estimator_training as distribute_coordinator_training
---> 30 from tensorflow.python.distribute import parameter_server_strategy_v2
31 from tensorflow.python.util import compat_internal
32 from tensorflow.python.util import function_utils
/usr/local/lib/python3.6/dist-packages/tensorflow/python/distribute/parameter_server_strategy_v2.py in <module>
26
27 from tensorflow.python.distribute import distribute_lib
---> 28 from tensorflow.python.distribute import distribute_utils
29 from tensorflow.python.distribute import parameter_server_strategy
30 from tensorflow.python.distribute import sharded_variable
/usr/local/lib/python3.6/dist-packages/tensorflow/python/distribute/distribute_utils.py in <module>
372 # (synchronization=ON_READ, aggregation=NONE,SUM,MEAN,ONLY_FIRST_REPLICA)
373 VARIABLE_POLICY_MAPPING = {
--> 374 vs.VariableSynchronization.AUTO: values_lib.AutoPolicy,
375 vs.VariableSynchronization.ON_WRITE: values_lib.OnWritePolicy,
376 vs.VariableSynchronization.ON_READ: values_lib.OnReadPolicy,
AttributeError: module 'tensorflow.python.distribute.values' has no attribute 'AutoPolicy'
Is there any particular reason as to why is this happening?
Thank you in advance.
My guess is this could be related to a version mismatch between the versions you're using for tensorflow and tensorflow_hub.
It looks like AutoPolicy was removed from TF in a recent commit, so if you built tensorflow from source and included this commit, then that could be the issue. If you want to build TF from source, checkout the latest official release before building (2.4.1).
I am running Python 3.6.5 and Pandas 0.25.2.
On attempting to style a pandas dataframe I am getting a specific error which can be generated by simplifying to this code:
import pandas as pd
import pandas.io.formats.style
The summary of the error generated is:
ImportError: The 'packaging._typing' package is required; normally this is bundled with this package so if you get this warning, consult the packager of your distribution.
The full error message is:
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-1-e9b944578fec> in <module>()
1 import pandas as pd
----> 2 import pandas.io.formats.style
~\Anaconda3\lib\site-packages\pandas\io\formats\style.py in <module>()
48
49
---> 50 class Styler:
51 """
52 Helps style a DataFrame or Series according to the data with HTML and CSS.
~\Anaconda3\lib\site-packages\pandas\io\formats\style.py in Styler()
109 """
110
--> 111 loader = jinja2.PackageLoader("pandas", "io/formats/templates")
112 env = jinja2.Environment(loader=loader, trim_blocks=True)
113 template = env.get_template("html.tpl")
~\Anaconda3\lib\site-packages\jinja2\loaders.py in __init__(self, package_name, package_path, encoding)
220 def __init__(self, package_name, package_path='templates',
221 encoding='utf-8'):
--> 222 from pkg_resources import DefaultProvider, ResourceManager, \
223 get_provider
224 provider = get_provider(package_name)
~\Anaconda3\lib\site-packages\pkg_resources\__init__.py in <module>()
79 from pkg_resources.extern import appdirs
80 from pkg_resources.extern import packaging
---> 81 __import__('pkg_resources.extern.packaging.version')
82 __import__('pkg_resources.extern.packaging.specifiers')
83 __import__('pkg_resources.extern.packaging.requirements')
~\Anaconda3\lib\site-packages\pkg_resources\_vendor\packaging\version.py in <module>()
9
10 from ._structures import Infinity, NegativeInfinity
---> 11 from ._typing import TYPE_CHECKING
12
13 if TYPE_CHECKING: # pragma: no cover
~\Anaconda3\lib\site-packages\pkg_resources\extern\__init__.py in load_module(self, fullname)
52 "normally this is bundled with this package so if you get "
53 "this warning, consult the packager of your "
---> 54 "distribution.".format(**locals())
55 )
56
I have tried reinstalling and upgrading the pandas installation, but each time I get the same error. This is being doine through an Anaconda environment.
Has anyone seen this error before? Is there a more detailed explanation that anyone can provide in an effort to solve this issue so that I can get the pandas styling working.
Thanks!
The correct way to do this is by:
from pandas.io.formats import style
This is because style is a module of pandas.io.formats package and the correct syntax is:
from package import module
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'.
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)`