Sheets API Python Error - python

I'm new to installing modules, etc, but believe I've done everything correctly and I'm getting errors. I'm following the instructions here:
https://developers.google.com/gdata/articles/python_client_lib#library
Steps:
1. downloaded Zip of gdata here:
https://github.com/google/gdata-python-client
2. unzipped and placed into my Scripts folder: C:\Python34\Scripts\gdata-python-client-master
3. went to cmd, above directory and installed: I did get a bunch of syntax errors (commas, etc), assuming this is why the next steps aren't working...
4. in python prompt, it says i have module:
[gdata 2.0.18 (c:\python34\lib\site-packages), google-api-python-client 1.4.2 (c:\python34\lib\site-packages), httplib2 0.9.2 (c:\python34\lib\site-packages), oauth2client 1.5.1 (c:\python34\lib\site-packages), pip 6.0.8 (c:\python34\lib\site-packages), pyasn1 0.1.9 (c:\python34\lib\site-packages), pyasn1-modules 0.0.8 (c:\python34\lib\site-packages), requests 2.7.0 (c:\python34\lib\site-packages), rsa 3.2.3 (c:\python34\lib\site-packages), setuptools 12.0.5 (c:\python34\lib\site-packages), simplejson 3.8.1 (c:\python34\lib\site-packages), six 1.10.0 (c:\python34\lib\site-packages), uritemplate 0.6 (c:\python34\lib\site-packages)]
5) But when I try to import gdata i get an error:
>>> import gdata.spreadsheet.service
Traceback (most recent call last):
File "<pyshell#6>", line 1, in <module>
import gdata.spreadsheet.service
File "C:\Python34\lib\site-packages\gdata\__init__.py", line 26, in <module>
import atom
File "C:\Python34\lib\site-packages\atom\__init__.py", line 132, in <module>
CreateClassFromXMLString)
File "C:\Python34\lib\site-packages\atom\__init__.py", line 96, in mark_deprecated
optional_warn_function.func_name = f.func_name
AttributeError: 'function' object has no attribute 'func_name'
Any ideas?

Instead of trying to unzip to install, use pip:
http://pip.readthedocs.org/en/stable/installing/
You can install the library using pip install gdata:
https://pythonhosted.org/gdata/installation.html
Update: pip is a good way to install, but this was not actually the problem - the actual root problem was gdata compatibility with python2 vs. python3. The fix that worked is described here: https://github.com/google/gdata-python-client/issues/29
Specifically running this in the site-packages directory:
2to3 -w atom gdata
Be warned this will change many files, so having a backup or recovery strategy in place before beginning is strongly advised.

Related

synology NAS, pip issue, python libraries

I recently acquired a NAS and trying to run a python script. Issue is that I cannot run the python script as a normal user (python script.py). Python is only running if I run as a sudo user (e.g., sudo python script.py)
When I run as a normal user, it does not detect the libraries such as pandas. But I do not want to run as a sudo because sudo would required a password.
I think the issue comes from the pip installation.
Do you know what could be the issue?
Greatly appreciate
In the terminal, when I run "pip list" as a normal user, it states 'ModuleNotFoundError: No module named 'pip._internal'
`
user#NAS:~$ pip list
Traceback (most recent call last):
File "/bin/pip", line 5, in <module>
from pip._internal.cli.main import main
ModuleNotFoundError: No module named 'pip._internal'
but when I run as a sudo:
user#NAS:~$ sudo pip list
Password:
Package Version
certifi 2022.6.15
charset-normalizer 2.1.1
idna 3.3
numpy 1.23.2
pandas 1.5.1
pip 22.3.1
pyasn1 0.4.5
pysmb 1.2.2
python-dateutil 2.8.2
pytz 2022.2.1
requests 2.28.1
setuptools 56.0.0
six 1.16.0
thread6 0.2.0
urllib3 1.26.12
wheel 0.38.4

Can not execute Robot Framework Properly (No module name Robot)

I had update Robot Framework into the newer version
Here are pip list that I had already download
Package Version
------------------------------- -----------
Appium-Python-Client 0.49
certifi 2020.6.20
chardet 3.0.4
decorator 4.4.2
django-robots 4.0
docutils 0.16
idna 2.10
kitchen 1.2.6
numpy 1.19.1
Pillow 7.2.0
pip 19.0.3
Pygments 2.6.1
PyPubSub 3.3.0
pywin32 228
requests 2.24.0
robot 20071211
robotframework 3.2.1
robotframework-appiumlibrary 1.5.0.4
robotframework-databaselibrary 1.2.4
robotframework-pythonlibcore 2.1.0
robotframework-requests 0.7.1
robotframework-ride 1.7.3.1
robotframework-selenium2library 3.0.0
robotframework-seleniumlibrary 3.3.1
robotframeworklexer 1.1
selenium 3.141.0
setuptools 40.8.0
six 1.15.0
urllib3 1.25.10
wxPython 4.0.7.post2
You are using pip version 19.0.3, however version 20.2.2 is available.
You should consider upgrading via the 'python -m pip install --upgrade pip' command.
Python that I chosen is 3.7.4
However, I need to executes the script, which it should be execute normally. However, I found that it caught error
Traceback (most recent call last):
File "d:\lib\runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "d:\lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "D:\Scripts\robot.exe\__main__.py", line 5, in <module>
ModuleNotFoundError: No module named 'robot'
that I don't understand that cause of error.
I have already got robot files as well
Have you found a solution yet? I doubt if your command to execute robot is correct.
robot <Path to robot file> will execute it.
for example robot Tests/my_robot_test.robot and if you have tags assigned, you can run specific tag test cases with robot -i <tag_id> Tests/my_robot_test.robot

When I do Flask run, it shows error : ModuleNotFoundError: No module named 'werkzeug.contrib'. Can anyone help me with this?

the exact error I get is :
flask.cli.NoAppException: While importing "application", an ImportError was raised:Traceback (most recent call last):
File "/home/harshit/.local/lib/python3.6/site-packages/flask/cli.py", line 240, in locate_app
__import__(module_name)
File "/home/harshit/Documents/project1/application.py", line 18, in <module>
Session(app)
File "/home/harshit/.local/lib/python3.6/site-packages/flask_session/__init__.py", line 54, in __init__
self.init_app(app)
File "/home/harshit/.local/lib/python3.6/site-packages/flask_session/__init__.py", line 61, in init_app
app.session_interface = self._get_interface(app)
File "/home/harshit/.local/lib/python3.6/site-packages/flask_session/__init__.py", line 93, in _get_interface
config['SESSION_USE_SIGNER'], config['SESSION_PERMANENT'])
File "/home/harshit/.local/lib/python3.6/site-packages/flask_session/sessions.py", line 313, in __init__
from werkzeug.contrib.cache import FileSystemCache
ModuleNotFoundError: No module named 'werkzeug.contrib'
I am trying to import sessions from Flask
Werkzeug 1.0.0 has removed deprecated code, including all of werkzeug.contrib. You should use alternative libraries for new projects. werkzeug.contrib.session was extracted to secure-cookie.
If an existing project you're using needs something from contrib, you'll need to downgrade to Werkzeug<1:
pip3 install Werkzeug<1
You will need to downgrade werkzeug version from 1.0.0 to 0.16.0
This solved the problem for me.
Just run the following commands in your project:
python3 -m pip uninstall werkzeug
and then
python3 -m pip install werkzeug==0.16.0
Either downgrade the version to 0.16.0 or replace werkzeug.contrib.cache with cachelib.
I can highly recommend upgrading the package. The deprecated module werkzeug.contrib is very easy to replace!
Install cachelib and replace all imports from:
from werkzeug.contrib.cache import FileSystemCache
to
from cachelib import FileSystemCache
If you still need deprecated code from werkzeug.contrib, you can downgrade Werkzeug version to less than 1.
pip install Werkzeug<1
For Python 3.8
python3 -m pip uninstall werkzeug
python3 -m pip install werkzeug
python3 -m pip install flask-session
After downgrading werkzeug:
pip install werkzeug==0.16.0
If you get the following:
flask 2.0.2 requires Werkzeug>=2.0, but you have werkzeug 0.16.0 which is incompatible
Consider doing:pip install flask==1.1.1
For my upgrade (0.15.5 -> 2.2.3) Everything is moved or removed from contrib to other modules. I recomend going to the documentation for your specific version of werkzeug and searching the library you are trying to import. I found mine!
from werkzeug.middleware.profiler import ProfilerMiddleware
app = ProfilerMiddleware(app)

Import of nltk version 3.2.3 fails with ImportError

I'm running python 2.7.13 under windows 10 and I'm struggling to get nltk properly running.
Here's what happens when I try to import nltk:
>>> import nltk
Traceback (most recent call last):
File "<pyshell#4>", line 2, in <module>
import nltk
File "C:\Python27\lib\site-packages\nltk-3.2.3-py2.7-win32.egg\nltk\__init__.py", line 128, in <module>
from nltk.chunk import *
File "C:\Python27\lib\site-packages\nltk-3.2.3-py2.7-win32.egg\nltk\chunk\__init__.py", line 157, in <module>
from nltk.chunk.api import ChunkParserI
File "C:\Python27\lib\site-packages\nltk-3.2.3-py2.7-win32.egg\nltk\chunk\api.py", line 13, in <module>
from nltk.parse import ParserI
File "C:\Python27\lib\site-packages\nltk-3.2.3-py2.7-win32.egg\nltk\parse\__init__.py", line 81, in <module>
from nltk.parse.corenlp import CoreNLPParser, CoreNLPDependencyParser
File "C:\Python27\lib\site-packages\nltk-3.2.3-py2.7-win32.egg\nltk\parse\corenlp.py", line 17, in <module>
import requests
ImportError: No module named requests
The following packages are installed:
cycler 0.10.0
functools32 3.2.3.post2
matplotlib 2.0.2
nltk 3.2.3
numpy 1.12.1
pyparsing 2.2.0
python-dateutil 2.6.0
pytz 2017.2
PyYAML 3.12
six 1.10.0
I have already tried to uninstall nltk and also uninstalled and reinstalled python and then I followed these instructions:
http://lizusefulstuff.blogspot.de/2012/03/how-to-install-nltk-package-for-python.html
However, with these instructions I get stuck with step 5. When I enter
python -m nltk.downloader
I get the message
C:\Python27\python.exe: No module named requests
Does anyone have a hint what I'm doing wrong here or what else I could try to get nltk running in my setup? I assume there is still a way to use nltk with python 2.7?
From what I found so far, it seems easier to install nltk with python 3.4 but I'd like to avoid a python upgrade, if possible, since aside from my nltk experiments I'm following along a coding tutorial that refers to python 2.7.
Thank you for any hints!
In the latest version of nltk (v3.2.3), there's an issue with "optional" dependency, see https://github.com/nltk/nltk/issues/1725
The ImportError would happen in any OS (Windows / Linux / Mac) since it's a python dependency issue.
This is due to the additional dependency that nltk.parse.corenlp needs but it isn't elegantly imported and the imports were exposed at the top level at https://github.com/nltk/nltk/blob/develop/nltk/parse/init.py#L81
To install nltk with requests to patch this problem:
pip install -U nltk[corenlp]
For fuzz-free installation, installs all packages that all nltk submodules would require:
pip install -U nltk[all]
Alternatively, you can install the request package separatedly:
pip install requests
Hopefully, issue #1725 gets resolved soon and a minor patched version of the release will be re-released soon.

Why do I get "ImportError: Twisted requires zope.interface 3.6.0 or later." when running stratum mining proxy?

The entire return when running "sudo python ./mining_proxy.py" is:
Traceback (most recent call last):
File "./mining_proxy.py", line 67, in <module>
from twisted.internet import reactor, defer
File "/Library/Python/2.7/site-packages/Twisted-13.2.0-py2.7-macosx-10.8-intel.egg/twisted/__init__.py", line 53, in <module>
_checkRequirements()
File "/Library/Python/2.7/site-packages/Twisted-13.2.0-py2.7-macosx-10.8-intel.egg/twisted/__init__.py", line 51, in _checkRequirements
raise ImportError(required + ".")
ImportError: Twisted requires zope.interface 3.6.0 or later.
This leads me to believe that zope.interface is not installed. So I try to install it:
sudo easy_install zope.interface
Searching for zope.interface
Best match: zope.interface 4.1.1
Processing zope.interface-4.1.1-py2.7-macosx-10.8-intel.egg
zope.interface 4.1.1 is already the active version in easy-install.pth
Using /Library/Python/2.7/site-packages/zope.interface-4.1.1-py2.7-macosx-10.8-intel.egg
Processing dependencies for zope.interface
Finished processing dependencies for zope.interface
I also find this post which says you basically need to put an init.py into the folder. So I do:
sudo touch /usr/local/lib/python2.7/site-packages/zope.interface-4.1.1/__init__.py
I try to run mining proxy again, same error. Please help.
I had the same error.
After googling around I found that the touch should be in a different place:
sudo touch /usr/local/lib/python2.7/site-packages/zope/__init__.py
however it didn't work.
I just fixed it using virtualenv
steps here:
pip install virtualenv virtualenvwrapper
mkvirtual stratum-proxy
pip install https://github.com/slush0/stratum-mining-proxy.git
pip install zope2
After those step inside the virtualenv stratum-proxy was working successfully.
hope it helps

Categories