ModuleNotFoundError: No module named 'msgpack', but msgpack is already installed - python

I'm on Windows using PowerShell and I'm trying to run a python script that calls another script that imports msgpack. My msgpack version is 1.0.2.
> python3 .\testing.py
Traceback (most recent call last):
File "C:\<path>\testing.py", line 1, in <module>
import b0RemoteApi
File "C:\<path>\b0RemoteApi.py", line 7, in <module>
import msgpack
ModuleNotFoundError: No module named 'msgpack'

I solved the issue. For anyone else who had this problem, I had two versions of Python installed, 3.8 and 3.9. msgpack was installed in the 3.8 directory and PowerShell was using Python 3.9, so I uninstalled the older version and reinstalled msgpack.

Related

How to resolve openssl not found error while installing new Python version with Pyenv on M1 Mac OS Ventura 13.1?

The system is M1 processor on MacOS Ventura 13.1. While installing a new version with pyenv, it throws following error regarding openssl not found on the system. openssl is already installed with the version number LibreSSL 3.3.6
Traceback (most recent call last):
File "<string>", line 1, in <module>
ModuleNotFoundError: No module named 'readline'
WARNING: The Python readline extension was not compiled. Missing the GNU readline lib?
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/Users/divyesh.parmar#postman.com/.pyenv/versions/3.10.6/lib/python3.10/ssl.py", line 99, in <module>
import _ssl # if we can't import it, let the error propagate
ModuleNotFoundError: No module named '_ssl'
ERROR: The Python ssl extension was not compiled. Missing the OpenSSL lib?
I've mostly tried approaches mentioned on this thread, but none of that seems to lead to anywhere. How to resolve this?
After looking at several Github threads on Pyenv project, one of the simplest method worked like a charm.
# Providing an incorrect openssl version forces a proper openssl version to be downloaded and linked during the build
export PYTHON_BUILD_HOMEBREW_OPENSSL_FORMULA=openssl#1.0
After setting this, upon running the command to install any version, it will automatically download and link the required version of openssl
Reference : https://github.com/pyenv/pyenv/issues/1768#issuecomment-1423144852
You can use a higher version of openssl with :
export CONFIGURE_OPTS="--with-openssl=$(brew --prefix openssl)"

ImportError: No module named 'pip._vendor.requests' for python3

Have installed pip3 via sudo apt-get. But while trying to check the pip3 --version, its throwing
ImportError: No module named 'pip._vendor.requests'
How do i fix this?
server -- Linux Debian 4.9.65-3,
Python version -- Python 3.5.3
p.s. have tried uninstalling and reinstalling pip3 but no luck.
Full stack trace:-
Traceback (most recent call last): File "/usr/bin/pip3", line 9, in
from pip import main File "/usr/lib/python3/dist-packages/pip/init.py", line 21, in
from pip._vendor.requests.packages.urllib3.exceptions import DependencyWarning ImportError: No module named 'pip._vendor.requests'

Cheetah package installation error -on python 3

Getting below error while installing Cheetah package (Cheetah-2.4.4) with python 3.4.3
Traceback (most recent call last):
File "setup.py", line 10, in <module>
import SetupTools
ImportError: No module named 'SetupTools'
Tries many ways resolving this but no luck. Can any one pls help me what is missing here.
This should be fixed in Cheetah 3, released today. Cheetah3 works with Python 3.3+.
Use pip install Cheetah for python 2.x and pip3 install Cheetah3 for python 3.x

How to use Python 3 (3.5) as the default interpreter in my virtual environment?

I ran into problems when I installed Python 3.5 on Mac. I wanted to use Python 3.5 as the interpreter when I ran my Django development server. I got this issue when I tried it (I know I must install a virtualenv, read below):
$ python3 manage.py runserver
Traceback (most recent call last):
File "manage.py", line 7, in <module>
from mezzanine.utils.conf import real_project_name
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/Mezzanine-4.0.1-py3.5.egg/mezzanine/utils/conf.py", line 7, in <module>
from django.conf import global_settings as defaults
ImportError: No module named 'django'
The first was when I tried installing pip packages it installed by default on the Python 2.7 in my virtual environment:
pip install django==1.9rc2
Collecting django==1.9rc2
Downloading Django-1.9rc2-py2.py3-none-any.whl (6.4MB)
100% |████████████████████████████████| 6.4MB 66kB/s
Installing collected packages: django
Successfully installed django-1.9rc2
I use Django so I tried also install a virtual environment for the first time. First I tried it with pip, but that didn't work.
So how do I setup so that my Python3.5 is the default usage when using Python interpreter and in my virtual environment? I can't figure this out or I have done something wrong in my process.
Edit:
Thanks for the answer and comment. I tried with the both solutions and the same error persisted. See output below:
$ virtualenv -p /Library/Frameworks/Python.framework/Versions/3.5/bin/python3.5 Django/
Running virtualenv with interpreter /Library/Frameworks/Python.framework/Versions/3.5/bin/python3.5
Traceback (most recent call last):
File "/Library/Python/2.7/site-packages/virtualenv.py", line 14, in <module>
import shutil
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/shutil.py", line 10, in <module>
import fnmatch
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/fnmatch.py", line 15, in <module>
import functools
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/functools.py", line 21, in <module>
from collections import namedtuple
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/collections/__init__.py", line 16, in <module>
from reprlib import recursive_repr as _recursive_repr
File "/Library/Python/2.7/site-packages/reprlib/__init__.py", line 7, in <module>
raise ImportError('This package should not be accessible on Python 3. '
ImportError: This package should not be accessible on Python 3. Either you are trying to run from the python-future src folder or your installation of python-future is corrupted.
My virtualenv version: 13.1.2
Your error is related to a known virtualenv bug regarding python-future and mixing up the 2.7 and 3.x module paths, the solution is to downgrade virtualenv to a version < 12.04, 12.0.2 is suggested in the link.
Firstly, If you are going to use multiple versions of python,then you must use Virtual Env.Also then Create your virtualenv using the following command so that it uses python 3.5 as default environment :
virtualenv -p python3 envname
and then install django in the virtualenv.after activating your virtualenv

I'm having troubles getting pybrain working through anaconda

Here is my problem:
After I managed to install anaconda (having python 3.4), I apparently managed to install pybrain too. But when i use 'import pybrain' from anaconda or from the terminal too I get this error:
>>> import pybrain
Traceback (most recent call last):
File "<ipython-input-2-0fb7233d2a8c>", line 1, in <module>
import pybrain
File "//anaconda/lib/python3.4/site-packages/PyBrain-0.3-py3.4.egg/pybrain/__init__.py", line 1, in <module>
from structure.__init__ import *
ImportError: No module named 'structure'
Simply running sudo pip3 install git+https://github.com/pybrain/pybrain.git worked for me after having the same issue.
The version up on PyPi isn't Python 3 compatible.
Installing the latest commit directly using pip3 should take care of your old package (from PyPi) as well.

Categories

Resources