Attribute error: module 'collections' has no attribute 'MutableSequence' PYTHON/SMARTSHEET SDK - python

I installed the Smartsheet Python sdk, imported the smartsheet module but am getting an error when I want to run the script. The error is localized to the smartsheet module and says that collections module is missing Mutable Sequence. I have already tried adding:
from collections.abc import MutableSequence
and had no change.
import smartsheet
import logging
import os
_dir = os.path.dirname(os.path.abspath(__file__))
This is what pops up in the terminal.
File "C:\Users\jhorvath\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\smartsheet\smartsheet.py", line 34, in <module>
from .models import Error, ErrorResult
File "C:\Users\jhorvath\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\smartsheet\models\__init__.py", line 21, in <module>
from .access_token import AccessToken
File "C:\Users\jhorvath\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\smartsheet\models\access_token.py", line 20, in <module>
from ..types import *
File "C:\Users\jhorvath\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\smartsheet\types.py", line 29, in <module>
class TypedList(collections.MutableSequence):
AttributeError: module 'collections' has no attribute 'MutableSequence'

A "quick and dirty" solution (I have this one - Python 3.10):
Path you-python-installation\python\Lib\site-packages\smartsheet
File
types.py
Line 29
class TypedList(collections.MutableSequence):
Replace with
class TypedList(collections.abc.MutableSequence):
I think Сolleagues from smartsheet - will fix the compatibility problem (at least - I believe it)
The main reason is
Deprecated since version 3.3, will be removed in version 3.10

Another solution I used is to modify the affected .py file in downloaded library from Smartsheet and change
import collections
to
import collections.abc as collections

If you are not able to edit the package as recommended in the first solution, use Python 3.9 that is the last version to support collections Mutable Sequence.

Related

Python3: import pandas_datareader ImportError

I'm pretty new to Python, but have Python 3.6 installed, and running a few other programs perfectly. I'm trying to pull data using the pandas_datareader module but keep running into this issue. Operating system: OSX.I've visited the other threads on similar errors and tried their methods to no avail.
Additional concern: When using Sublime Text, if I run it as a Python (instead of Python3) build, it funcitons fine, but all my other accompanying programs are written on Python3. Is there a way of making this work on 3.6 that I'm missing?
I have already visited the 'is_list_like' error question, and have changed the fred.py file to pandas.api.types in the import line.
Traceback (most recent call last):
File
"/Users/scottgolightly/Desktop/python_work/data_read_practice.py", line
3, in <module>
import pandas_datareader.data as web
File
"/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-
packages/pandas_datareader/__init__.py", line 2, in <module>
from .data import (DataReader, Options, get_components_yahoo,
File
"/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-
packages/pandas_datareader/data.py", line 14, in <module>
from pandas_datareader.fred import FredReader
File
"/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-
packages/pandas_datareader/fred.py", line 1, in <module>
from pandas.core.common import is_list_like
ImportError: cannot import name 'is_list_like'
As has been noted, is_list_like has been moved from pandas.core.common to pandas.api.types.
There are several paths forward for you.
My (highly) recommended solution: download Conda and set up an environment with a version of Pandas prior to v0.23.0.
You can install the development version of Pandas, with a patch in place:
pip install git+https://github.com/pydata/pandas-datareader.git
Since you say that you have a version of Pandas in a different environment that works, I suspect the Python calling it is version 2.X. If so, try using past.autotranslate to import the older version of Pandas.
If this working version of Pandas actually belongs to a Python 3.X site-packages, then you can manually import it using:
sys.path.insert(0, '/path/to/other/pandas')
Small workaround is to define it like this:
import pandas as pd
pd.core.common.is_list_like = pd.api.types.is_list_like
import pandas_datareader

Python requests and beautifulsoup module not importing

I have installed python in my mac. When I type python3in terminal and then import requests and bs4 it imports it and run the program correctly.
But when I run it on python file as python3 file_name.py, it gives the following error:
import requests
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/requests/__init__.py", line 52, in <module>
from .packages.urllib3.contrib import pyopenssl
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/requests/packages/__init__.py", line 27, in <module>
from . import urllib3
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/requests/packages/urllib3/__init__.py", line 8, in <module>
from .connectionpool import (
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/requests/packages/urllib3/connectionpool.py", line 3, in <module>
import logging
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/logging/__init__.py", line 28, in <module>
from string import Template
File "/Users/dark_archer/Desktop/src/string.py", line 1, in <module>
n1,n2=map(int,input().split())
ValueError: not enough values to unpack (expected 2, got 0)
I got the same error with both python 3.5 and python 3.6.
The issue is that you named a module string.py so it's confusing the importer because the logging module is also trying to import something from the standard library module string.py. This causes an issue known as "name shadowing" where your locally defined module is loaded instead of the the standard library module.
When your version of string.py gets imported it triggers the code which is causing your error.
As an easy fix, try to rename your string.py module to something else.
For more info on name shadowing check out the "The name shadowing trap" section of this link: http://python-notes.curiousefficiency.org/en/latest/python_concepts/import_traps.html

ImportError: cannot import name is_python_keyword

I am trying to execute a python script , but I get an error on line
from jinja2.utils import Markup, concat, escape, is_python_keyword, next
ImportError: cannot import name is_python_keyword
I checked there is no file named is_python.py
Looking at the source code for 2.3.1 they have a line:
from keyword import iskeyword as is_python_keyword
They are using the builtin keyword module.
The current version is 2.7.3 so it seems they have changed the code and it is no longer available.
You could use the above import from the builtin module instead.

Sublime text plugin development

I have developed a command line python application to save a source file with syntax highlight (pygments) as a evernote note; well this work fine.
Now i would like to integrate this application in a sublime text 2 plugin, but my application needs some python modules to work (like evernote sdk, pygments library).
Project's structure is following:
Package
|
---My_Plugin
|
-----evernote/
|
-----pygments/
|
myplugin_main.py
I'm tring to include modules as following:
import sys, os
sys.path.append(os.path.abspath(os.path.dirname(__file__))+"/evernote")
sys.path.append(os.path.abspath(os.path.dirname(__file__))+"/pygments")
from evernote.api.client import EvernoteClient
import evernote.edam.type.ttypes as Types
import evernote.edam.notestore.NoteStore as NoteStore
import evernote.edam.userstore.UserStore as UserStore
I'm having a lot of problems to work this external modules; i don't understand why it seems that the application don't see modules.
From the sublime console, when i try to save i receive something like this:
Reloading plugin /home/sergioska/.config/sublime-text-2/Packages/evernote-sublime-plugin/ever.py
Traceback (most recent call last):
File "./sublime_plugin.py", line 62, in reload_plugin
File "./ever.py", line 3, in <module>
from evercode import EverCode
File "./evercode.py", line 7, in <module>
from evernote.api.client import EvernoteClient
File "/home/sergioska/.config/sublime-text-2/Packages/evernote-sublime-plugin/evernote/evernote/api/client.py", line 5, in <module>
import oauth2 as oauth
File "./oauth2/__init__.py", line 32, in <module>
import httplib2
File "./httplib2/__init__.py", line 915, in <module>
class HTTPSConnectionWithTimeout(httplib.HTTPSConnection):
AttributeError: 'module' object has no attribute 'HTTPSConnection'
of course I tried to add also oauth2 and httplib2 like i say above, but nothing.
How can i do to solve this problem?
As for the error you got, could it be similar issue to this?
HTTPSConnection module missing in Python 2.6 on CentOS 5.2
For the sublime 2 plugin, this is what I found on github: https://github.com/jamiesun/SublimeEvernote
and I forked it and updated as non OAuth version with Evernote SDK: https://github.com/rekotan/SublimeEvernote
Those above might help you to build your own.

python & suds "ImportError: cannot import name getLogger"

I'm using Ubuntu 11.04 (natty). I have been using Suds to consume a SOAP web service. Everything was working fine... until it wasn't. I can no longer import Suds. I've uninstalled and re-installed Suds from the Ubuntu repositories but still get the same import error (see IDLE traceback below). I'm using Python 2.7.1 and Suds 0.4.1-2. Does anyone have any ideas on how to solve this problem??
>>> import suds
Traceback (most recent call last):
File "<pyshell#1>", line 1, in <module>
import suds
File "/usr/lib/pymodules/python2.7/suds/__init__.py", line 154, in <module>
import client
File "/usr/lib/pymodules/python2.7/suds/client.py", line 23, in <module>
import suds.metrics as metrics
File "/usr/lib/pymodules/python2.7/suds/metrics.py", line 23, in <module>
from logging import getLogger
ImportError: cannot import name getLogger
>>>
logging is a standard module of Python. There are several possible reasons why Python can't find it anymore:
The is another logging module in the path (print sys.path to get a list of paths Python will search)
Someone changed PYTHONPATH (the default Python search path)
Someone messed with the Python installation (deleted the logging module)

Categories