Import error ROS python3 opencv - importerror

Is there a way where I can import both opencv2 and rospy successfully in python3. Because right now I get an error.
Traceback (most recent call last): File "", line 1, in ImportError: /opt/ros/kinetic/lib/python2.7/dist-packages/cv2.so: undefined symbol: PyCObject_Type
removing the line "source /opt/ros/kinetic/setup.bash" from my bash file solves the problem of importing opencv but now I cant import rospy

This happens since ROS creates its own open cv ,which is compatible with python2 only.To solve this
You need to rename the Cv of Ros located at /opt/ros/kinetic/lib/python2.7/dist-packages/cv2.so to something else, example cv_renamed.so and then you should be able to import it
Since Ros cannot coexist for python2 and python3 , It is recommended to have a virtual environment(conda,virtual env)

Related

PyAudio import error : ImportError: DLL load failed: The specified module could not be found

I encountered an import problem by PyAudio.
I have a winodws 10, 64 bit, and use Anaconda and Spyder IDE with python 3.7.
I installed PyAudio in Ananconda, ran as administrator, with these commands :
cd
conda install -c conda-forge PyAudio
The installation ran without any problems.
I then restarted both Anaconda and SPYDER. PyAudio now shows up in Anaconda's list of installed packages.
When I try to import Pyaudio in Spyder (IPython console), I encounter this error message :
[1]: import pyaudio
Could not import the PyAudio C module '_portaudio'.
Traceback (most recent call last):
File "", line 1, in
import pyaudio
File "C:\ProgramData\Anaconda3\lib\site-packages\pyaudio.py", line 116, in
import _portaudio as pa
ImportError: DLL load failed: The specified module could not be found.
I tried to fix it by answers to similar ImportError message issued, while other users tried to import other packages like SKlearn ... , but with no success.
Your problem (and mine) are the same. The issue is, unfortunately, the version of python you're running (in tandem with your OS).
Check out this link:
https://people.csail.mit.edu/hubert/pyaudio/#:~:text=Note%3A%20As%20of%20this%20update,4.
Under the INSTALLATION section in the link for WINDOWS, PyAudio's latest version (0.2.11) is compatible with Python versions: 2.7, 3.4, 3.5, 3.6.
My current python is 3.8.5, so you (and I) could never use PyAudio unless they added compatibilities or we revert to an above python version.
I tried to install portaudio using
conda install portaudio
but it seems like it didn't work as it should be. However,
conda install -c anaconda portaudio
solved the problem.
see the official anaconda page

how to fix "no module named openpyxl " in (pycharm) python 3.7?

I was trying to add excel spreadsheets so i had to import openpyxl command which throws me this:
Traceback (most recent call last):
File "/home/prasad/PycharmProjects/test/hello.py", line 1, in <module>
import openpyxl as xl
ModuleNotFoundError: No module named 'openpyxl'
i tried pip3 install openpyxl , but it didn't rectify the error.
I created a file call test.py to help you to install any module using Pycharm and I ran it from Ctrl + Shift + F10. Then I get this error which you already got.
Just click on openpyxl and you'll see some red bulb. Just click it or enter Alt + Enter keywords, you'll get below image.
Just click the install package openpyxl and it will be installing to your machine.
After that you'll get this notification, if you get this mean it successfully installed in to your computer and now your error should be gone (in the import statement).
I think your problem is solved. Like this you can install any package using Pycharm in your current environment which is setup to run your program. For more information check this Install, uninstall, and upgrade packages article from Pycharm official.

ModuleNotFoundError: No module named 'numpy' in Python 3.7 on Mac

I have python 3.7.2. I am trying to import numpy and keep getting this error. I use the terminal on Mac OS Mojave V 10.14.2
import numpy
Traceback (most recent call last):
File "< stdin >", line 1, in < module >
ModuleNotFoundError: No module named 'numpy'
I think this could be a duplicate of this question.
numpy is not part of the python standard library and needs to be installed separately.
There are instructions for mac install in the question I linked for you.

Unable to install Python cloudstorage module

I'm using Ubuntu 17.04 on Dell Laptop.
I'm trying to install the cloudstorage module.
When installing the module with Python2 using sudo, it works, however on importing it fails:
python storage2.py
Traceback (most recent call last):
File "storage2.py", line 6, in
import cloudstorage as gcs
File "/home/maxim/.local/lib/python2.7/site-packages/cloudstorage/init.py", line 56
def get_driver(driver: DriverName) -> Drivers:
Also, when I try installing this module with Python3 it fails:
https://apaste.info/QKYD
Why the import fails and how to fix it?
How to install this module in Python3?

libjingle compiling error

When compiling libjingle, on running the 'hammer.sh' on the swtoolkit,
i get the following import error,
root#den-pc:~/tejesh/libjingle-0.6.14/talk# sh ../../swtoolkit/hammer.sh
Traceback (most recent call last):
File "../../swtoolkit/wrapper.py", line 44, in <module>
import SCons.Script
ImportError: No module named SCons.Script
so how do i fix this import error... any suggestions?
i already setup the environment variables for scons (SCONS_DIR) and have all the libraries installed..
If you have SCons correctly installed, then it sounds like a problem with python not being able to find it. In addition to the SCONS_DIR environment variable, try including the SCons location in the PYTHONPATH environment variable.
when you install scons,in the README file,you can use:
# python setup.py install --standalone-lib
that can make scons modules into pythonpath.