No module named 'info' on fresh Python 3 installation - python-3.x

I did a fresh python3 installation on OSX via homebrew:
brew install python3
Then I created a virtual environment for my project and installed scipy and scikits.samplerate:
virtualenv -p /usr/local/bin/python3 pythen_env
pip install scipy
pip install scikits.samplerate
However, when I try to import a function from scikits.samplerate, I get the following error:
>>> from scikits.samplerate import resample
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/my/project/path/pythen_env/lib/python3.6/site-packages/scikits/samplerate/__init__.py", line 4, in <module>
from info import __doc__
ModuleNotFoundError: No module named 'info'
Info happens to be the first module from the package itself that is imported in __init__.py.
Strangely, the module info.py exists in /my/project/path/pythen_env/lib/python3.6/site-packages/scikits/samplerate/:
ls /my/project/path/pythen_env/lib/python3.6/site-packages/scikits/samplerate/
__init__.py setup.py tests __pycache__
info.py setuphelp.py version.py
The error also happens when I try the same without virtualenv, as well as for other packages. How could I start to debug this issue?

The problem seems to be that the package scikits.samplerate does not support Python 3.X (see issue). However, there is a fork which supports Python 3.X. You can install it via
$ pip install git+https://github.com/gregorias/samplerate.git
As always: people can make anything they like in repositories. I did not check which changes gregorias made.

the git version does support py3
https://github.com/cournape/samplerate
(merged the PR from #gregorias)
I should find the time and procedure to update pypi too...

Related

ModuleNotFound : No module named "git"

I was updating my git repo using the below command
python3 helper.py --update SomeName
But it is showing error like:
Traceback (most recent call last):
File "helper.py", line 13, in <module>
import git
ModuleNotFoundError: No module named 'git'
I have installed both Python 3 (3.8.5) and Python 2 (2.7.18).
Following Installing GitPython, a simple pip install GitPython should be enough.
If not, check gitpython-developers/GitPython issue 1051:
Even though I don't know what is causing this I do know that GitPython 2.x is supposed to work with Python 2 and 3, whereas GitPython 3 only works with Python 3.
It's hard to understand what exactly happened here, but when running pip3 install GitPython I am also unable to successfully run import git.
My best guess is that pip installs things outside of the PYTHONPATH, which certainly is surprising
What worked in my case, on Windows, was
python3 -m pip install gitpython
Even after installing GitPython through pip3, the module was not being found, even if I included the appropriate paths. What worked is the command I mention.

Imported module was not found?

I am building a web scraper and I am trying to import the 'requests' package but I am getting an error. I am being told the following:
ModuleNotFoundError: No module named 'requests'
Full Error:
(venv) USERs-MacBook-Pro:Scraper user$ /usr/local/opt/python#3.9/bin/python3.9 /Users/user/git/ML/Python/Practice/Scraper/Scraper.py
Traceback (most recent call last):
File "/Users/user/git/ML/Python/Practice/Scraper/Scraper.py", line 1, in <module>
import requests
ModuleNotFoundError: No module named 'requests'
Steps I took when setting up project:
python3 -m venv project_name/venv
source project_name/venv/bin/activate
python3 -m pip install SomePackage
Confirmation package and dependences were installed:
(venv) USERs-MacBook-Pro:Scraper user$ pip list
Package Version
---------- ---------
certifi 2020.12.5
chardet 4.0.0
idna 2.10
pip 20.2.3
requests 2.25.1
setuptools 49.2.1
urllib3 1.26.2
By using the absolute path to system Python like that:
/usr/local/opt/python#3.9/bin/python3.9 /Users/user/git/ML/Python/Practice/Scraper/Scraper.py
you are using system's Python 3.9 and the packages that are installed for that one although you are in a virtual environment.
When creating a virtual environment you are creating a separate environment with the specified python version and all the packages you install with pip are installed to this environment and this python version.
You can better understand that if you run:
which python
inside your virtual environment.
This will show you the python that is used when you run python inside your venv and it's going to be different than
/usr/local/opt/python#3.9/bin/python3.9
So, by having installed requests using pip inside your environment, it is installed in the environments python which is executed when you run just python.
To sum up, to use the packages installed inside your venv with pip you should run your script (after activating the venv) with:
python /Users/user/git/ML/Python/Practice/Scraper/Scraper.py

pip3 works with python3.2 but won't work with python3.3

I have created a virtual environment for python3
virtualenv -p /usr/bin/python3 myenv
Everything works ok and pip installs python3 packages. Then I need to upgrade my python3.2 to python3.3. I am using ubuntu 12.04, so I need to do what Luper Rouch suggests here through ppa
I copy /usr/bin/python3.3 into myenv/bin/python3, thus (inside myenv):
python --version
returns Python 3.3.5. But then pip stops working failing with
pip install urllib3
Traceback (most recent call last):
File "mypathtoevn/bin/pip", line 7, in <module>
from pip import main
ImportError: No module named 'pip'
Then I understand that I have to use
pip3.3 install <package_name>
but I can't find any other pip*.* version either globally or inside virtualenv in my system.
How can I get pip3.3 or any other pip version?
Thanks
The ppa you have installed does not contain pip. The python package installer is itself installed with easy_install. On the question you linked to follow the later parts of this answer
Basically, calling
wget http://python-distribute.org/distribute_setup.py
python distribute_setup.py
easy_install pip
should be sufficient. You should use the easy_install command of your Python3.3 install.
Check with
which python
where your python comes from, and search for easy_install in that path. In your case you know where it resides: Your virtualenv.

pip isn't working when importing something

To install pymongo for pypy3 2.1 Beta 1, I installed pip using the following commands:
wget https://bitbucket.org/pypa/setuptools/raw/bootstrap/ez_setup.py
./pypy ez_setup.py --user
where pypy is the executable of pypy3 2.1 Beta 1. After that, pip and pip-3.2 will come to the current directory. But when running pip or pip-3.2, I get the error:
Traceback (most recent call first):
File "pip-3.2", line 5, in <module>
from pkg_resources import load_entry_point
zipimport.ZipImportError: pip==1.4.1
It seems that the problem comes from from pkg_resources import load_entry_point of the pip/pip-3.2. But this statement runs OK when I put it in pypy or python3 IDLE. What's the matter? How to solve this problem and proceed to install pymongo for pypy3 2.1 Beta 1? Thank you.
PS: I'm using Ubuntu. python3 is installed in the system. If u need any other information pertaining to solving the question, please comment.

xlutil install -Python

I'm trying to install xlutils package to access xls sheets in Python but unfortunately I'm unable to install it.
Python Version=3.1.1
I downloaded the tar file from this location-http://pypi.python.org/pypi/xlutils to python31/tools/scripts directory..This is where my setup.py is located..
Then tried to unzip using 7Z file and run the setup.py install command from this directory.
and got the following..Ran the
C:\Python31\Tools\Scripts>setup.py install
running install
running build
running build_scripts
running install_scripts
running install_egg_info
Removing C:\Python31\Lib\site-packages\UNKNOWN-0.0.0-py3.1.egg-info
Writing C:\Python31\Lib\site-packages\UNKNOWN-0.0.0-py3.1.egg-info
>>> import xlutils
Traceback (most recent call last):
File "<pyshell#3>", line 1, in <module>
import xlutils
ImportError: No module named xlutils
Do I need to install xlrd and xlwt before installing xlutils?
Please provide your inputs
You're running setup.py from the wrong folder - you need to run it where you've unpacked the zip file.
Yes, it does need xlrd and xlwt - See here
xlrd and xlwt aren't available for Python 3 yet (I'm working on it for xlrd).
Today I have the same problem. You can try the below steps:
Install xlrd and xlwt;
Install setuptools
Install xlutils.
Good Luck.

Resources