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)
Related
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
>>> import yaml
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/tools/python_libs/yaml/__init__.py", line 2, in <module>
from error import *
ModuleNotFoundError: No module named 'error'
I don't see how to set my PYTHONPATH with anaconda3.
Am I missing an install step?
I have the same situation, but with the ROS. The same error reproduces when you use python 3 instead of python 2. You can see corresponding discussion
here. For some reasons I would like to use python3 instead of python2, so I need to find out, how to get rid of this error.
I can suggest two solutions right now:
Either use python2 instead of python3, as suggested in ROS discussion
Or try to install yaml with pip3 for python3 (not pip). I think it may help in this situation. See here for installation instructions.
So today i started working on a simple python module, but i cant make it work.
the module itself works, but when i have uploaded it to PyPI and i then install it using Pip, it wont work.
Please notice that it is built for python-2.7
The source code can be seen here:
https://github.com/1m0r74l17y/FortyTwo
and it can be downloaded using:
sudo pip install FortyTwo
whenever i try to run a test program like this:
from FortyTwo import *
FortyTwo.nope()
It just gives me an error:
Traceback (most recent call last):
File "test.py", line 3, in
FortyTwo.nope()
AttributeError: 'module' object has no attribute 'fortytwo'
I would really appreciate any help, as it might lead me onto what i have to do to fix the problem.
You would need to do the following.
from FortyTwo import fortytwo
fortytwo.nope()
If you want to call nope directly from FortyTwo you would need to import that function in __init__.py.
e.g.
from FortyTwo.fortytwo import nope
def Start():
"""No Clue what to add here"""
What if you do
from FortyTwo import fortytwo
fortytwo.nope()
* credits to eandersson.
I am attempting to install ckan on my system and I'm following the install from package directions (http://docs.ckan.org/en/latest/maintaining/installing/install-from-package.html). All the dependencies were installed correctly and the ckan package itself downloaded without error. When I went to run the install I got a module missing error for what to me looks like a trivial python module that should be there.
jeremy#jeremy-HP-ProBook-4530s:~$ sudo dpkg -i python-ckan_2.5-trusty_amd64.deb
[sudo] password for jeremy:
(Reading database ... 214293 files and directories currently installed.)
Preparing to unpack python-ckan_2.5-trusty_amd64.deb ...
Unpacking python-ckan (2.5.1-trusty1) over (2.5.1-trusty1) ...
Setting up python-ckan (2.5.1-trusty1) ...
Traceback (most recent call last):
File "/usr/lib/ckan/default/bin/paster", line 7, in <module>
from paste.script.command import run
File "/usr/lib/ckan/default/local/lib/python2.7/site-packages/paste/script/command.py", line 3, in <module>
import pkg_resources
File "/usr/lib/ckan/default/local/lib/python2.7/site-packages/pkg_resources/__init__.py", line 36, in <module>
import plistlib
File "/usr/lib/python2.7/plistlib.py", line 62, in <module>
import datetime
ImportError: No module named datetime
/var/lib/dpkg/info/python-ckan.postinst: line 18: initctl: command not found
Site datapusher already enabled
I've confirmed that datetime is installed with a quick python -c 'import datetime' run. At this point I have done a little bit of digging and haven't been able to find anywhere else where this is duplicated nor exactly how to resolve this. Any help or advice is greatly appreciated.
Looking around for the error from plistlib it looks like the same error affecting https://bugs.launchpad.net/ubuntu/+source/python2.7/+bug/1368144
Unfortunately I'm not sure how this would have come about. I'll continue digging and see if I can find out more, but it isn't anything I've seen before but it definitely appears virtualenv related.
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.