Am trying to use clr.AddReference and clr.AddReferenceToFile to import an assembly, but python(2.7) keeps making this error:
Traceback (most recent call last):
File "<pyshell#5>", line 1, in <module>
clr.AddReference("UnityEngine")
AttributeError: 'module' object has no attribute 'AddReference'
Can anyone tell me how to fix this.
Once I met this issue.
There is a package named clr while the pythonnet package's alias is also clr.
So I removed clr by "pip uninstall clr" and then installed pythonnet by 'pip install pythonnet'.
Finally, everything works well.
You must be using the wrong 'clr' module.
remove it
pip uninstall clr
And then install pythonnet
pip install pythonnet
run the code
import clr
dir(clr)
if the reasult is as ['StyleBuilder', 'builtins', 'cached',....]
then the problem is your IDE is installing the WRONG Clr module
Related
I currently have opencv-python 4.5.3.56 installed and running in Python 3.8. However, whenever I try to use the library, I get the error:
Traceback (most recent call last):
File "c:/Users/ryck5/Documents/FA2021/ECEG301/camerademo/color_detection.py", line 108, in <module>
dj.open_camera()
cap = opencv.VideoCapture(0)
AttributeError: module 'opencv' has no attribute 'VideoCapture'
I also tried print(opencv.__version__), but that gave me the same error, just with version instead of VideoCapture. I've tried uninstalling and reinstalling opencv countless times, using the opencv-contrib-python library instead, but nothing has worked. Any help would be much appreciated!
opencv library is used as cv2 namespace in python environment. Most probably you have installed python-opencv and using it.
Try:
import cv2 and then use cv2.VideoCapture().
Also, this is why opencv.__version__ is giving you error as there is no opencv object or library here. Try cv2.__version__.
I'm trying to install pyperclip on Python 3.8.6 on Windows 10, and after typing
pip3 install pyperclip
in cmd it tells me that pyperclip has been successfully installed, but when I then try import pyperclip on they Python shell I get the following error message:
Traceback (most recent call last):
File "<pyshell#0>", line 1, in <module>
import pyperclip
ModuleNotFoundError: No module named 'pyperclip'
I've tried uninstalling and reinstalling pyperclip using pip, and also installing an older version of the package (1.8.0) but the error persists.
Thanks for your help!
While installing the socketio package for python using pip3 install socketio, I got the following results:
ERROR: launchpadlib 1.10.13 requires testresources, which is not installed.
WARNING: The scripts easy_install and easy_install-3.8 are installed in '/home/bill/.local/bin' which is not on PATH.
Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
Successfully installed netifaces-0.10.6 setuptools-3.3 socketio-0.2.1
Although I was able to import socketio successfully, pip3 seems corrupted(?).
Specifically, when trying to run anything including pip3, even pip3 by itself in the terminal, I get the same error:
Traceback (most recent call last):
File "/usr/bin/pip3", line 6, in <module>
from pkg_resources import load_entry_point
File "/home/<username>/.local/lib/python3.8/site-packages/pkg_resources.py", line 1479, in <module>
register_loader_type(importlib_bootstrap.SourceFileLoader, DefaultProvider)
AttributeError: module 'importlib._bootstrap' has no attribute 'SourceFileLoader'
Error in sys.excepthook:
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/apport_python_hook.py", line 144, in apport_excepthook
with os.fdopen(os.open(pr_filename,
FileNotFoundError: [Errno 2] No such file or directory: '/var/crash/_usr_bin_pip3.1000.crash'
Original exception was:
Traceback (most recent call last):
File "/usr/bin/pip3", line 6, in <module>
from pkg_resources import load_entry_point
File "/home/<username>/.local/lib/python3.8/site-packages/pkg_resources.py", line 1479, in <module>
register_loader_type(importlib_bootstrap.SourceFileLoader, DefaultProvider)
AttributeError: module 'importlib._bootstrap' has no attribute 'SourceFileLoader'
I tried reinstalling pip3 but it didn't help. I migrated from ubuntu to mint thinking it is something buggy with the distribution but same results. I also corrupted ubuntu when I tried to remove python and reinstall it since I couldn't use pip, but, you know what they say, live and learn.
Edit: Nothing on using pip3: module "importlib._bootstrap" has no attribute "SourceFileLoader" works for me.
I am currently using linux mint 20, but I experienced the same problem on ubuntu 20.04 and 20.04.1.
Any ideas would be appreciated!
Perhaps you meant this socketio instead?: https://pypi.org/project/python-socketio
python3 -m pip install python-socketio
The package literally named "socketio" seems like it may simply be old and unsupported1, while "python-socketio" seems alive and developed 2 3
To that end, it's often valuable to take a look at similar packages and also to watch out for typosquatting et al. when installing packages via pip!
Edit: Martijn Peters makes a good point that this is the socketio you are looking for: https://pypi.org/project/python-socketio
Read on if you need a solution for the original one you posted about.
Summary: pip3 install git+https://github.com/allenmcgehee/socketio-0.2.1-patched
I was able to reproduce this in a docker container running ubuntu:20.04 exactly as you described which gave me some hope that I could help out.
I found that socketio had a dependency for setuptools==3.3 which seemed odd to me, but lines up with why the core functionality of pip was breaking after installing socketio.
I am not sure where this package is maintained as there is no git repo referenced. I did find a Russion website in the PKG-INFO, but I wasn't sure where to go from there...
Here is a version of socketio with a requirement of setuptools>=42 so that nothing gets broken: https://github.com/allenmcgehee/socketio-0.2.1-patched
And finally, here is the single command that should install socketio for you without breaking pip:
pip3 install git+https://github.com/allenmcgehee/socketio-0.2.1-patched
**I am assuming you've already fixed pip.
This happened to me with a different module. My solution was to down-grade the version of pip and the version of the module. So, for you the answer would be to run:
python -m pip install pip== (previous version of your pip)
python -m pip uninstall socketio
python -m pip install socketio==0.2.0
With reference to the following instructions:
http://open-babel.readthedocs.io/en/latest/UseTheLibrary/Python_Pybel.html
After installing the windows 64-bit version of Openbabel 2.4.1 from http://openbabel.org/wiki/Category:Installation , I have installed openbabel and pybel through pip.
>>>pip install pybel
>>>pip install openbabel
I am trying to find the molecular weight of a molecule in an sdf format (file name is mol1.sdf present in the same directory)
The python file (test.py) that I've created is as follows:
import pybel
mol = pybel.readfile("sdf", "mol1.sdf").next()
print (mol.molwt)
Here's what happens in the command prompt:
>>> python test.py
Traceback (most recent call last):
File "test.py", line 2, in <module>
mol = pybel.readfile("sdf", "mol1.sdf").next()
AttributeError: 'module' object has no attribute 'readfile'
But according to the sample code in the reference link above, there is an attribute called 'readfile' that reads the file and format. Am I missing something? THanks
I found that I made a mistake. It turns out that I hadn't installed the Python Bindings v1.8 for the program.
You installed the "wrong" pybel. For those who use Acaconda, you should search openbabel and install it. After you install openbabel, you should be able to use pybel. Don't search and install pybel directly, pybel itself doesn't work.
You should do the following:
conda uninstall pybel, conda install -c openbabel openbabel
I have Anaconda installed in my system and I recently installed OpenCV 3.0.0 using the instructions given on this page. But when I open python and type import cv2, it throws me the following error:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: /home/ashutosh/anaconda2/lib/libstdc++.so.6: version `GLIBCXX_3.4.21' not found (required by /usr/local/lib/python2.7/site-packages/cv2.so)
I dont't know why am I getting this error. I also put the PYTHONPATH in the bashrc file, sourced it but nothing happened.
sudo apt-get install libgcc
This dependency caused the error.