Brand new raspberry pi using the debian image from the pi site.
I used sudo apt-get install python-pycurl
My script looks like this
import pycurl
c = pycurl.Curl()
c.setopt(c.POST, 1)
c.setopt(c.SSL_VERIFYPEER, 1)
c.setopt(c.CAINFO, '/etc/ssl/certs/ca-certificates.crt')
c.setopt(c.URL, 'https://theurl.com')
c.setopt(c.USERPWD, 'user:pass')
c.setopt(c.POSTFIELDS, 'Field1=This&Field2=That')
c.perform()
I'm getting this
Traceback (most recent call last):
File "pycurl.py", line 1, in <module>
import pycurl
File "/home/pi/test/pycurl.py", line 3, in <module>
c = pycurl.Curl()
AttributeError: 'module' object has no attribute 'Curl'
Look at the path in the traceback. It looks like you may be importing your own module called pycurl.py, not the actual pycurl library. Try renaming that file to something else so Python imports the real pycurl.
python first checks in the current directory for a module, then in the python directory.
rename your file to mypicurl.py or something. otherwise, you're just importing the script.
edit: i just saw your comment, and this means you havn't installed it properly. try a reinstall or install from a .deb
Related
Question - How do I fix my code so I don't get this error? I'd like output to be placed in my clipboard buffer (I'm on a Mac)?
What I've tried - Printing output to the console works great! I've tried uninstalling and reinstalling via pip pyperclip.
What I notice - my code doesn't call 'NSString' so I haven't a clue where I've gone astray. object is the <class 'str'>.
Where might I find helpful documentation on how to solve this sort of problem that might come up in the future?
#!/usr/bin/env python3
# encoding: utf-8
import pyperclip
output = f"""
Below are the titles and a one-sentence summary/meaning/'stinger' of zettel
I've birthed into existence and their ideas I'm grappling.
"""
# print(output)
# print(type(output))
pyperclip.copy(output)
Output
(base) ➜ ~ python wiwov1.py
Traceback (most recent call last):
File "/Users/will/wiwov1.py", line 79, in <module>
pyperclip.copy(output)
File "/usr/local/lib/python3.9/site-packages/pyperclip/__init__.py", line 659, in lazy_load_stub_copy
return copy(text)
File "/usr/local/lib/python3.9/site-packages/pyperclip/__init__.py", line 136, in copy_osx_pyobjc
newStr = Foundation.NSString.stringWithString_(text).nsstring()
AttributeError: module 'Foundation' has no attribute 'NSString'
I'd try to reinstall pyperclip:
pip uninstall pyperclip
pip install --upgrade pyperclip
Also I would update the code:
import pyperclip
output = "Below are the titles and a one-sentence summary/meaning/'stinger' of zettel \n I've birthed into existence and their ideas I'm grappling."
pyperclip.copy(output)
Not my code, I was trying a tool that includes the osascript library.
In the lib, at the line path = temp.tempfile() the error in the title is raised.
The temp library, correctly imported by the authors, has the following code itself:
f, path = tempfile.mkstemp()
The tempfile.mkstemp() part works like a charm.
So, since we are talking about two very common and widely used libs and since I'm apparently unable to find anything relevant on Google, I'm kind pretty sure there's some problem with my local configuration.
I'm on macOS, using python3 (3.7), no virtual envs.
The command pip list --outdated tells me that exactly those two libs are actually outdated, but apparently there is no way pip will download the updated versions. (note: my pip is correctly referring to the python3 binary, not macOS outdated python 2.7)
osascript 0.0.0 2020.7.2 sdist
temp 0.0.0 2020.7.1 sdist
Any ideas?
Steps to reproduce the error:
>>> import temp
>>> temp.tempfile()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.7/site-packages/temp/__init__.py", line 15, in tempfile
f, path = tempfile.mkstemp()
AttributeError: 'function' object has no attribute 'mkstemp'
This is a bug in package temp which is a dependency of osascript. The package imports tempfile and then immediately overwrites it with a function tempfile. Report the bug.
Currently I am using Python 3.7, and Ubuntu 18.04. I downloaded wxPython from pip, but when I tried to import wx in my terminal, I get this error:
>>> import wx
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/aleejandrof/anaconda3/lib/python3.7/site-packages/wx/__init__.py", line 17, in <module>
later on, when I tried other ways like and "._core import" I received an error like this:
ImportError: /home/aleejandrof/anaconda3/bin/../lib/libpangoft2-1.0.so.0: undefined symbol: pango_font_description_set_variations
After reading some posts here, I tried deleting the wx.py and wx.pyc files, which didn't work. The same happened when I read that downloading the main excecutable file would make the import occur with no errors, but it popped the same errors.
AttributeError: module 'wx' has no attribute '__version__'
I am trying to run a GUI pipeline, which works with wxPython. I'm thankful in advance, if any of you has suggestions.
When I made an environment of ubuntu18.04 using docker, ran into the same problem.
I had multiple libpangoft2-1.0.so.0 files.
It seemed the problem was /opt/conda/lib/libpangoft2-1.0.so.0 was looked up.
To change the name of the file solved the problem.
find / -name libpangoft2-1.0.so.0
/opt/conda/lib/libpangoft2-1.0.so.0
/opt/conda/pkgs/pango-1.42.4-h049681c_0/lib/libpangoft2-1.0.so.0
/usr/lib/x86_64-linux-gnu/libpangoft2-1.0.so.0
mv /opt/conda/lib/libpangoft2-1.0.so.0 /opt/conda/lib/libpangoft2-1.0.so.0-void
You may want to try:
conda install -c asmeurer pango
My whole code is
import warc
f = warc.open("file.warc.gz")
for record in f:
print record['WARC-Target-URI'], record['Content-Length']
But it gives me this error:
File "warc.py", line 1, in <module>
import warc
File "/path/warc.py", line 3, in <module>
f = warc.open("file.warc.gz")
AttributeError: 'module' object has no attribute 'open'
I just installed warc with sudo pip install warc, following these instructions. The code too is just a copy and paste from that page.
I don't understand why the import doesn't work. I tried to upgrade the installation too, but it's already up to date.
I finally discovered the problem reading this question. I had called my script warc.py, and that generated the conflict. Careful how you name your files.
I installed redis-py on CentOS and Ubuntu. On both I get the same error when trying to access it.
redis-py AttributeError: 'module' object has no attribute
If I use the python prompt in the same directory as the source this will work:
>>> import redis
>>> r = redis.Redis(host='localhost', port=6379, db=0)
but if I change directories it will give the error.
>>> import redis
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "redis.py", line 4, in <module>
print redis.__version__
AttributeError: 'module' object has no attribute '__version__'
Trying with a .py script always gives the error. Any idea what I'm doing wrong, and how to fix it. Probably a newbie Python thing...
You're naming a module you're working on redis.py and Python is importing that instead of the real redis module. Don't do that, or change sys.path to make sure the current working directory is last rather than first in the lists of directories to search.
i have this error in tornado and it was because i install redis on python 2.7 and install in python3 too , i uninstall redis from python2.7 and re_install in python3 and solve the Problem!