I just installed Python 3.5 on windows 10 and was trying to run the startup example from the IDE I choose (Rodeo). The example gives an error when trying to import ggplot. Specifically, at this call
from ggplot import ggplot, aes, geom_bar
which gives me:
ImportErrorTraceback (most recent call last)
in ()
----> 1 from ggplot import ggplot, aes, geom_bar
C:\Anaconda3\lib\site-packages\ggplot\__init__.py in ()
17
18
---> 19 from .geoms import geom_area, geom_blank, geom_boxplot, geom_line, geom_point, geom_jitter, geom_histogram, geom_density, geom_hline, geom_vline, geom_bar, geom_abline, geom_tile, geom_rect, geom_bin2d, geom_step, geom_text, geom_path, geom_ribbon, geom_now_its_art, geom_violin, geom_errorbar, geom_polygon
20 from .stats import stat_smooth, stat_density
21
C:\Anaconda3\lib\site-packages\ggplot\geoms\__init__.py in ()
----> 1 from .geom_abline import geom_abline
2 from .geom_area import geom_area
3 from .geom_bar import geom_bar
4 from .geom_bin2d import geom_bin2d
5 from .geom_blank import geom_blank
C:\Anaconda3\lib\site-packages\ggplot\geoms\geom_abline.py in ()
----> 1 from .geom import geom
2
3 class geom_abline(geom):
4 """
5 Line specified by slope and intercept
C:\Anaconda3\lib\site-packages\ggplot\geoms\geom.py in ()
1 from __future__ import (absolute_import, division, print_function,
2 unicode_literals)
----> 3 from ..ggplot import ggplot
4 from ..aes import aes
5
C:\Anaconda3\lib\site-packages\ggplot\ggplot.py in ()
19 from . import discretemappers
20 from .utils import format_ticks
---> 21 import StringIO
22 import urllib
23 import base64
ImportError: No module named 'StringIO'
So StringIO cannot be imported. I read here that StringIO doens't exist in that form anymore, but the fixes over there did not help me out. Any tips? What might be relevant (although I cannot judge that) is that I'm unable to update Scipy or ggplot via pip install ggplot --upgrade, but I thought/ read somewhere that this happens because I do not have a built in compiler on my windows machine. Many thanks in advance!
Well, I found a solution myself. pip install ggplot --upgrade failed for me, but
conda install -c conda-forge ggplot did the trick.
Related
I am trying to use one package that somebody developed on GitHub called PyLipid.
The first parts of the code are importing various packages, but I am continuously getting this error, showed bellow:
%matplotlib inline
import pylipid
import collections
from pylipid.api import LipidInteraction
# print(pylipid.__version__) # make sure pylipid version is later than 1.4
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
Input In [37], in <cell line: 4>()
2 import pylipid
3 import collections
----> 4 from pylipid.api import LipidInteraction
File ~/miniconda3/envs/work/lib/python3.10/site-packages/pylipid/api/__init__.py:32, in <module>
1 ##############################################################################
2 # PyLipID: A python module for analysing protein-lipid interactions
3 #
(...)
14 # copies or substantial portions of the Software.
15 ##############################################################################
17 r"""
18 PyLipID class
19 =============
(...)
29
30 """
---> 32 from .api import LipidInteraction
File ~/miniconda3/envs/work/lib/python3.10/site-packages/pylipid/api/api.py:30, in <module>
28 import pandas as pd
29 from tqdm import trange, tqdm
---> 30 from p_tqdm import p_map
31 from ..func import cal_contact_residues
32 from ..func import Duration
File ~/miniconda3/envs/work/lib/python3.10/site-packages/p_tqdm/__init__.py:1, in <module>
----> 1 from p_tqdm.p_tqdm import p_map, p_imap, p_umap, p_uimap, t_map, t_imap
3 __all__ = [
4 'p_map',
5 'p_imap',
(...)
9 't_imap'
10 ]
File ~/miniconda3/envs/work/lib/python3.10/site-packages/p_tqdm/p_tqdm.py:11, in <module>
1 """Map functions with tqdm progress bars for parallel and sequential processing.
2
3 p_map: Performs a parallel ordered map.
(...)
8 t_imap: Returns an iterator for a sequential map.
9 """
---> 11 from collections import Sized
12 from typing import Any, Callable, Generator, Iterable, List
14 from pathos.helpers import cpu_count
ImportError: cannot import name 'Sized' from 'collections' (/home/srdjanm/miniconda3/envs/work/lib/python3.10/collections/__init__.py)
Does anybody know how to solve this error? I have also posted the question on the webpage in github but it might take a while for someone to respond, also this seems to me like a more general problem. Is this the package or "python version" related issue?
You may want to modify one line in the library to it works. It was created a pull request in github of p_tqdm library
In file ~/miniconda3/envs/work/lib/python3.10/site-packages/p_tqdm/p_tqdm.py modify line 11 from
from collections import Sized
to
from collections.abc import Sized
Even though I have installed both the libraries several times using different orders in different virtual environments, I'm still facing an issue where I'm not able to import and use certain geospatial libraries like esda and libpysal. The following error shows up:
ImportError Traceback (most recent call last)
C:\Users\SLAADM~1\AppData\Local\Temp/ipykernel_35328/2667884714.py in <module>
3 import numpy as np
4 import matplotlib.pyplot as plt
----> 5 import esda
6 import libpysal as lps
7 import pysal
c:\users\sla admin\appdata\local\programs\python\python39\lib\site-packages\esda\__init__.py in <module>
5
6 """
----> 7 from . import adbscan
8 from .gamma import Gamma
9 from .geary import Geary
c:\users\sla admin\appdata\local\programs\python\python39\lib\site-packages\esda\adbscan.py in <module>
8 import pandas
9 import numpy as np
---> 10 from libpysal.cg.alpha_shapes import alpha_shape_auto
11 from scipy.spatial import cKDTree
12 from collections import Counter
c:\users\sla admin\appdata\local\programs\python\python39\lib\site-packages\libpysal\__init__.py in <module>
25 Tools for creating and manipulating weights
26 """
---> 27 from . import cg
28 from . import io
29 from . import weights
c:\users\sla admin\appdata\local\programs\python\python39\lib\site-packages\libpysal\cg\__init__.py in <module>
9 from .sphere import *
10 from .voronoi import *
---> 11 from .alpha_shapes import *
c:\users\sla admin\appdata\local\programs\python\python39\lib\site-packages\libpysal\cg\alpha_shapes.py in <module>
22
23 try:
---> 24 import pygeos
25
26 HAS_PYGEOS = True
c:\users\sla admin\appdata\local\programs\python\python39\lib\site-packages\pygeos\__init__.py in <module>
----> 1 from .lib import GEOSException # NOQA
2 from .lib import Geometry # NOQA
3 from .lib import geos_version, geos_version_string # NOQA
4 from .lib import geos_capi_version, geos_capi_version_string # NOQA
5 from .decorators import UnsupportedGEOSOperation # NOQA
ImportError: DLL load failed while importing lib: The specified procedure could not be found.
Would really appreciate any help in making this work. Please throw any suggestions you might have at me.
install pygeos i.e conda install pygeos
it worked for me
I found same issue when running example code from a couple of years ago. The pysal API has changed.
Import libpysal first then import the esda libraries eg
import libpysal
from esda.moran import Moran
from esda.smaup import Smaup
see
https://pysal.org/esda/generated/esda.Moran.html
My code
!pip install stldecompose
from stldecompose import decompose
Error Msg
ImportError Traceback (most recent call last)
in
2 # Install the library via PIP
3 get_ipython().system('pip install stldecompose')
----> 4 from stldecompose import decompose, forecast
~/opt/anaconda3/lib/python3.7/site-packages/stldecompose/init.py in
----> 1 from .stl import decompose, forecast
~/opt/anaconda3/lib/python3.7/site-packages/stldecompose/stl.py in
3 from pandas.core.nanops import nanmean as pd_nanmean
4 from statsmodels.tsa.seasonal import DecomposeResult
----> 5 from statsmodels.tsa.filters._utils import _maybe_get_pandas_wrapper_freq
6 import statsmodels.api as sm
7
ImportError: cannot import name '_maybe_get_pandas_wrapper_freq' from 'statsmodels.tsa.filters._utils' (/Users/georgeng/opt/anaconda3/lib/python3.7/site-packages/statsmodels/tsa/filters/_utils.py)
You have two pathway to go about this:
If you are running statsmodels==0.11.0, statsmodels.tsa.filters._utils function was removed from the library.
Alternatively you may use statsmodels.tsa.seasonal.STL, which gives similar functionality. See its documentation:
https://www.statsmodels.org/stable/generated/statsmodels.tsa.seasonal.STL.html#statsmodels.tsa.seasonal.STL
Downgrade to pip install statsmodels==0.10.2
I run this simple code on google colab.
###cell 1 : `!pip install syft`
###cell 2 : `import syft as sy`
and i got this error :
ModuleNotFoundError: No module named 'syft_proto.messaging.v1.protocol_pb2'
There is the full error message
---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-3-9aeadc8ee442> in <module>()
----> 1 import syft as sy
7 frames
/usr/local/lib/python3.6/dist-packages/syft/__init__.py in <module>()
41
42 # Import grids
---> 43 from syft.grid.private_grid import PrivateGridNetwork
44 from syft.grid.public_grid import PublicGridNetwork
45
/usr/local/lib/python3.6/dist-packages/syft/grid/private_grid.py in <module>()
9 # Syft imports
10 from syft.grid.abstract_grid import AbstractGrid
---> 11 from syft.workers.node_client import NodeClient
12 from syft.messaging.plan.plan import Plan
13 from syft.frameworks.torch.tensors.interpreters.additive_shared import AdditiveSharingTensor
/usr/local/lib/python3.6/dist-packages/syft/workers/node_client.py in <module>()
5
6 # Syft imports
----> 7 from syft.serde import serialize
8 from syft.messaging.plan import Plan
9 from syft.codes import REQUEST_MSG, RESPONSE_MSG
/usr/local/lib/python3.6/dist-packages/syft/serde/__init__.py in <module>()
----> 1 from syft.serde.serde import *
/usr/local/lib/python3.6/dist-packages/syft/serde/serde.py in <module>()
10 from syft.workers.abstract import AbstractWorker
11
---> 12 from syft.serde import msgpack
13
14 ## SECTION: High Level Public Functions (these are the ones you use)
/usr/local/lib/python3.6/dist-packages/syft/serde/msgpack/__init__.py in <module>()
----> 1 from syft.serde.msgpack import serde
2 from syft.serde.msgpack import native_serde
3 from syft.serde.msgpack import torch_serde
4 from syft.serde.msgpack import proto
5
/usr/local/lib/python3.6/dist-packages/syft/serde/msgpack/serde.py in <module>()
57 from syft.messaging.plan import Plan
58 from syft.messaging.plan.state import State
---> 59 from syft.messaging.protocol import Protocol
60 from syft.messaging.message import Message
61 from syft.messaging.message import Operation
/usr/local/lib/python3.6/dist-packages/syft/messaging/protocol.py in <module>()
11 from syft.workers.abstract import AbstractWorker
12 from syft.workers.base import BaseWorker
---> 13 from syft_proto.messaging.v1.protocol_pb2 import Protocol as ProtocolPB
14
15
ModuleNotFoundError: No module named 'syft_proto.messaging.v1.protocol_pb2'
Hope that you can help me. Thank you
Thank you for answers. It works when i downgrade these two packages, it is a temporary problem due to pysyft developers.
!pip install syft=="0.2.2a1"
!pip install syft_proto=="0.1.1a1.post17"
It looks the module you are trying to use is either deprecated or has a new version. See here the file is not active.
Try searching if a newer version of this protocol exists or any similar protocol that can cater to your needs.
Edit:
It may also be that you are using an older version Syft and so I recommend you to upgrade your pip and Syft. Follow the instructions here
you can upgrade both to their latest version which are kept compatible!
!pip install --upgrade syft
!pip install --upgrade syft_proto
ImportError Traceback (most recent call last)
<ipython-input-1-76a01d9c502b> in <module>
----> 1 import spacy
~\Anaconda3\envs\nlp_course\lib\site-packages\spacy\__init__.py in <module>
8 from thinc.neural.util import prefer_gpu, require_gpu
9
---> 10 from .cli.info import info as cli_info
11 from .glossary import explain
12 from .about import __version__
~\Anaconda3\envs\nlp_course\lib\site-packages\spacy\cli\__init__.py in <module>
----> 1 from .download import download
2 from .info import info
3 from .link import link
4 from .package import package
5 from .profile import profile
~\Anaconda3\envs\nlp_course\lib\site-packages\spacy\cli\download.py in <module>
9
10 from ._messages import Messages
---> 11 from .link import link
12 from ..util import prints, get_package_path
13 from .. import about
~\Anaconda3\envs\nlp_course\lib\site-packages\spacy\cli\link.py in <module>
7 from ._messages import Messages
8 from ..compat import symlink_to, path2str
----> 9 from ..util import prints
10 from .. import util
11
~\Anaconda3\envs\nlp_course\lib\site-packages\spacy\util.py in <module>
25 # Import these directly from Thinc, so that we're sure we always have the
26 # same version.
---> 27 from thinc.neural._classes.model import msgpack
28 from thinc.neural._classes.model import msgpack_numpy
29
ImportError: cannot import name 'msgpack' from 'thinc.neural._classes.model' (C:\Users\salwa\Anaconda3\envs\nlp_course\lib\site-packages\thinc\neural\_classes\model.py)
The problem is with thinc, a dependency of spaCy, as you can see here: ImportError: cannot import name 'msgpack' from 'thinc.neural._classes.model'
Follow Ines's (a core developer of spaCy) suggestion that you can find here,
It looks like you might have ended up with conflicting installationds
and dependencies – for example, the latest version of spaCy, but an
older version of its dependency, Thinc. In cases like this, it often
helps to just start out with a clean environment and reinstall from
scratch.