I've got the same error message both on my desktop and on my Windows 2008 R2 server -
Here's the code -
from sharepoint import SharePointSite, basic_auth_opener
server_url = "http://sharepoint/"
site_url = server_url + "path/to/page/Forms/AllItems.aspx"
opener = basic_auth_opener(server_url, "acct", "password")
site = SharePointSite(site_url, opener)
for sp_list in site.lists:
print sp_list.id, sp_list.meta['Title']
When running it I get the following error -
Traceback (most recent call last):
File "C:\temp\sharepoint.py", line 1, in <module>
from sharepoint import SharePointSite, basic_auth_opener
File "C:\temp\sharepoint.py", line 1, in <module>
from sharepoint import SharePointSite, basic_auth_opener
ImportError: cannot import name SharePointSite
What's going on? The package is in the location -
C:\Python27\Lib\site-packages\sharepoint
I can import other packages just fine. for example, lxml works fine.
from lxml import etree
no problems.
You named your script sharepoint.py and that masks the library:
Traceback (most recent call last):
File "C:\temp\sharepoint.py", line 1, in <module>
from sharepoint import SharePointSite, basic_auth_opener
File "C:\temp\sharepoint.py", line 1, in <module>
from sharepoint import SharePointSite, basic_auth_opener
ImportError: cannot import name SharePointSite
Look at the filenames in the traceback, you can see that the script ends up importing itself; when Python starts your script it loads it as __main__, so importing sharepoint loads your own file one more time, at which point it fails to import itself again.
Rename your script to something else.
Related
Why am I still getting this error while having created the secret.py file as required?
import twitterbot as tb
import secrets, sys
hashtag = sys.argv[1]
credentials = secrets.get_credentials()
bot = tb.Twitterbot(credentials['email'], credentials['password'])
bot.login()
bot.like_retweet(hashtag)
PS C:\Users\tqnam\OneDrive\Desktop\Quốc Nam\Twitter Automation> python main.py {hashtag}
Traceback (most recent call last):
File "C:\Users\tqnam\OneDrive\Desktop\Quốc Nam\Twitter Automation\main.py", line 8, in <module>
credentials = secrets.get_credentials()
AttributeError: module 'secrets' has no attribute 'get_credentials'
PS C:\Users\tqnam\OneDrive\Desktop\Quốc Nam\Twitter Automation>
I use python 3.6, and I am trying to play an audio file with pyo, but when I try to run it, I get this message;
Traceback (most recent call last):
File "C:\Python27\pyotest.py", line 1, in
from pyo import *
File "C:\Python27\pyo.py", line 2, in
NameError: name 'Server' is not defined
My code:
from pyo import *
s = Server().boot()
s.start()
sf = SfPlayer("C:\Users\*****\Music\sound.mp3", speed=1, loop=True).out()
Looks like you have created the file C:\Python27\pyo.py. So instead of the actual pyo module getting imported, your file gets imported.
Rename the file C:\Python27\pyo.py and any pyc file (C:\Python27\pyo.pyc) associated with it and try again
I am trying to connect Pepper to Dialogflow. The Dialogflow SDK is stored in the project folder/lib. The python version used by Pepper is 2.7. I use python 2.7.9.
self.folderName = os.path.join(self.framemanager.getBehaviorPath(self.behaviorId), "..\lib")
if self.folderName not in sys.path:
sys.path.append(self.folderName)
self.log(self.folderName)
import apiai
ai = apiai.ApiAI(CLIENT_ACCESS_TOKEN)
When running the code, I got the errors:
[ERROR] behavior.box :_safeCallOfUserMethod:281 _Behavior__lastUploadedChoregrapheBehaviorbehavior_1338328200__root__test_1: Traceback (most recent call last):
File "C:\PROGRA~2\ALDEBA~1\CHOREG~1.1\lib\naoqi.py", line 271, in _safeCallOfUserMethod
func()
File "<string>", line 23, in onInput_onStart
File "C:\Users\AppData\Roaming\PackageManager\apps\.lastUploadedChoregrapheBehavior\behavior_1\..\lib\apiai\__init__.py", line 9, in <module>
from .requests.query import Entry
File "C:\Users\AppData\Roaming\PackageManager\apps\.lastUploadedChoregrapheBehavior\behavior_1\..\lib\apiai\requests\__init__.py", line 3, in <module>
from .request import Request
File "C:\Users\loadedChoregrapheBehavior\behavior_1\..\lib\apiai\requests\request.py", line 9, in <module>
from httplib import HTTPSConnection
ImportError: cannot import name HTTPSConnection
Any ideas how to solve it?
This program must be run on the robot, rather than on your computer.
I'm trying to use the following package: https://github.com/Anorov/cloudflare-scrape/blob/master/cfscrape/init.py
I have the following test file:
import cfscrape
import sys
import execjs
who = sys.argv[1]
scraper = cfscrape.create_scraper()
print scraper.get(who).content
Which is outputting the following error:
Traceback (most recent call last): File "test.py", line 1, in import cfscrape File "build/bdist.macosx-10.10-intel/egg/cfscrape/__init__.py", line 17, in EnvironmentError: Your Javascript runtime 'JavaScriptCore' is not supported due to security concerns. Please use Node.js, V8, or PyV8.
Can anyone point me in the right direction to change my JS_ENGINE from JavaScriptCore to NodeJs
I have problems when try to import pywhois module, i can import my own module but still have troubles when import pywhois. I moved the pywhois folder in my project folder domain, the screentshot is below:
This is the import and calling statment below:
import part:
from pywhois import *
calling part:
w = whois('hackbo.com')
self.response.out.write(w)
The problems is it will always throw a http 500 error, error text is below:
Traceback (most recent call last):
File "/home/li/Desktop/google_appengine/google/appengine/ext/webapp/__init__.py", line 700, in __call__
handler.get(*groups)
File "/home/li/Desktop/google_appengine/domain/main.py", line 43, in get
w = whois('hackbo.com')
File "pywhois/__init__.py", line 12, in whois
text = nic_client.whois_lookup(None, domain, 0)
File "pywhois/whois.py", line 157, in whois_lookup
result = self.whois(query_arg, nichost, flags)
File "pywhois/whois.py", line 100, in whois
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
AttributeError: 'module' object has no attribute 'socket'
What is this error means? why i could import my own module but can not import pywhois?
Google App Engine doesn't support the socket module, which pywhois uses. It allows you to import socket, but it's an empty module.
import whois
site = input ("Enter Site : ")
n = whois.whois (site)
print (n)
this is best whois
Enjoy that, easy.