Installing python module to Mac OS QGIS through console - python

My QGIS python console returns error
import tweepy
Traceback (most recent call last):
File "<input>", line 1, in <module>
File "/Applications/QGIS.app/Contents/MacOS/../Resources/python/qgis/utils.py", line 572, in _import
mod = _builtin_import(name, globals, locals, fromlist, level)
ImportError: No module named tweepy
I installed the python module to OS through pip but it is not available to QGIS python console. A previous question suggests it should have worked: Installing the Python geojson module on Mac OS X Yosemite to use with QGIS

Related

installing obdé library

i am trying to use obd library in python for my project; however when instaling it; i get the following problem:
PS C:\Users\DELL\Documents\OBD\project2> pip install "obd==0.7.1"
Could not import runpy module
Traceback (most recent call last):
File "<frozen runpy>", line 15, in <module>
File "<frozen importlib.util>", line 14, in <module>
File "C:\Users\DELL\AppData\Local\Programs\Python\Python311\Lib\contextlib.py", line 6, in <module>
from collections import deque
ImportError: cannot import name 'deque' from 'collections' (C:\Users\DELL\AppData\Local\Programs\Python\Python311\Lib\collections\__init__.py)
PS C:\Users\DELL\Documents\OBD\project2>
ps: python version : 3.11.1
obd version : 0.7.1
i want to install obd library and try a simple code with it

Can't import openCV in anaconda Python 3.10

I installed openCV onto Python 3.10 and it's erroring in the import stage.
Any ideas on what to try for this?
>>> import cv2
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\ProgramData\Anaconda3\envs\myenv\lib\site-packages\cv2\__init__.py", line 181, in <module>
bootstrap()
File "C:\ProgramData\Anaconda3\envs\myenv\lib\site-packages\cv2\__init__.py", line 153, in bootstrap
native_module = importlib.import_module("cv2")
File "C:\ProgramData\Anaconda3\envs\myenv\lib\importlib\__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
ImportError: DLL load failed while importing cv2: The specified module could not be found.
>>> ^Z
(myenv) C:\Users\Eli Rogers>python -V
Python 3.10.6
Here you are getting error because the interpreter has already started and when you have retype the python it is interpreting it as a variable so .
you can check out this :
NameError: name 'python' is not defined
where the same problem has discussed

Python Installation in local directory gives "ModuleNotFoundError": 'msvcrt'

I'm using my company's VM which already has Python 2.7 (comes with the OS) and Python 3.6.13 (Installed by the company)
Recently, there is a need to upgrade an application to latest version of Python ie: 3.10.2
So, I installed Python 3.10.2 in a local directory inside my $HOME. I referred to this link for the installation link.
While 2.7 & 3.6 are already there in the system.
Now, when I try to create a VENV with this python version (3.10.2), I see this error:
Traceback (most recent call last):
File "/export/home/sdc/python_versions/python310/python/lib/python3.10/subprocess.py", line 69, in <module>
import msvcrt
ModuleNotFoundError: No module named 'msvcrt'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/export/home/sdc/python_versions/python310/python/lib/python3.10/runpy.py", line 187, in _run_module_as_main
mod_name, mod_spec, code = _get_module_details(mod_name, _Error)
File "/export/home/sdc/python_versions/python310/python/lib/python3.10/runpy.py", line 146, in _get_module_details
return _get_module_details(pkg_main_name, error)
File "/export/home/sdc/python_versions/python310/python/lib/python3.10/runpy.py", line 110, in _get_module_details
__import__(pkg_name)
File "/export/home/sdc/python_versions/python310/python/lib/python3.10/venv/__init__.py", line 10, in <module>
import subprocess
File "/export/home/sdc/python_versions/python310/python/lib/python3.10/subprocess.py", line 74, in <module>
import _posixsubprocess
ModuleNotFoundError: No module named '_posixsubprocess'
I found some solutions like this one: link but I cannot figure out how it will translate in my case since my installation directory is not /usr/local/... It is $HOME/path/to/dir
Python on Linux does not have the msvcrt module at all. It's strictly Windows only. You seem to have miscompiled your Python somehow, since it also doesn't have the _posixsubprocess module (and msvcrt is used for Windows detection in subprocess.py).
May I recommend using pyenv or asdf for custom Python versions? They're less likely to miscompile Python.

Error importing scipy.linalg on windows (python 3.3)

I am using python 3.3 on Windows. I downloaded scipy-0.13.2.win32-py3.3.exe from scipy-lib and installed it. However, when I tried to load scipy.linalg, interpreter displayed the following errors:
>>> import scipy.linalg
Traceback (most recent call last):
File "<pyshell#0>", line 1, in <module>
import scipy.linalg
File "C:\Python33\lib\site-packages\scipy\linalg\__init__.py", line 157, in <module>
from .misc import *
File "C:\Python33\lib\site-packages\scipy\linalg\misc.py", line 5, in <module>
from . import blas
File "C:\Python33\lib\site-packages\scipy\linalg\blas.py", line 131, in <module>
from scipy.linalg import _fblas
ImportError: DLL load failed: The specified module could not be found.
How can I resolve this issue? Between, I checked installed library modules on my PC with the github modules at linealg-scipy and they are latest, so no issue there, I guess.
To fix this issue in both Python 2.7/3, you can install scipy from here
It will work better than the version from this deposit.

fix PYTHONHOME in order to import liblas module in Python

I have the following error message on windows 64-bit and Python 2.7.
the liblas module version is libLAS-1.7.0.win-amd64-py2.7.‌exe
import liblas
Traceback (most recent call last):
File "<interactive input>", line 1, in <module>
File "C:\Python27\lib\site-packages\liblas\__init__.py", line 2, in <module>
from core import get_version
File "C:\Python27\lib\site-packages\liblas\core.py", line 138, in <module>
las = ctypes.CDLL(os.path.join(local_dlls, lib_name))
File "C:\Python27\Lib\ctypes\__init__.py", line 365, in __init__
self._handle = _dlopen(self._name, mode)
WindowsError: [Error 193] %1 is not a valid Win32 application
The module is installed in
C:\Python27\Lib\site-packages\liblas
i used this module several times (it's a core module of my work), but today i have this problem. I unistalled liblas, reinstalled, unistalled all Python and all modules, and reinstall everything bit i have always the same problem.
If you have 64-bit version of Python installed and LibLAS dll 32-bit, then you can get this type of error. If so, then you can find 64-bit version of this library on this site (there are actually a lot of other 32-bit and 64-bit libraries for Python).

Categories