ModuleNotFoundError: No module named 'tools.nnwrap' - python

I tried to install torch using:
pip install torch
Installation started, but after a few seconds I got the error:
from tools.nnwrap import generate_wrappers as generate_nn_wrappers
ModuleNotFoundError: No module named 'tools.nnwrap'
OS: Windows

Anyone who is looking for the solution refer below:
It seems command to install torch not is working as expected, instead, you can try to install PyTorch using below command.
It's working and solved my above-mentioned issue.
Run below command(for below-specified OS, package-manager, Language):
# for OS: Windows, package-manager: pip, Language: python3.6 (below command is valid for only mentioned python 3.6)
pip3 install https://download.pytorch.org/whl/cu90/torch-1.1.0-cp36-cp36m-win_amd64.whl
pip3 install https://download.pytorch.org/whl/cu90/torchvision-0.3.0-cp36-cp36m-win_amd64.whl
For another version/type of the software (OS, package, Language) installed, the command must be generated from the below-mentioned link.
https://pytorch.org/get-started/locally/
Also, look for the Python version in your IDE(If you are using PyCharm) from the terminal using the command: python. If it returns 32bit this could happen, instead install Python 64-bit.

Follow the instructions on https://pytorch.org/get-started/locally/
Choose Package "Pip" if you want to pip install
It will give you output such as
pip3 install https://download.pytorch.org/whl/cu90/torch-1.1.0-cp37-cp37m-win_amd64.whl
pip3 install https://download.pytorch.org/whl/cu90/torchvision-0.3.0-cp37-cp37m-win_amd64.whl
Edit: new install instructions from pytorch.org shows commands such as
pip3 install torch===1.3.1 torchvision===0.4.2 -f https://download.pytorch.org/whl/torch_stable.html

To install stable version of pytorch in windows 10 for pycharm, following command should work.
pip install torch===1.4.0 torchvision===0.5.0 -f https://download.pytorch.org/whl/torch_stable.html

For what it's worth, on Windows 10 in Anaconda, the only command which worked for me was:
pip3 install https://download.pytorch.org/whl/cu90/torch-1.0.1-cp37-cp37m-win_amd64.whl

This worked for Windows 10 using Python-3.x pip
pip install torch==1.4.0+cpu torchvision==0.5.0+cpu -f https://download.pytorch.org/whl/torch_stable.html

For me this was fixed by checking my python version - I got this error with python 3.8, but the error went away when I downgraded to 3.7 (install instructions on the site only appear to go up to 3.7).

How I fix it in Windows 10 (x64)
31 March 2020
Install CUDA from here: https://developer.nvidia.com/cuda-downloads?target_os=Windows&target_arch=x86_64&target_version=10&target_type=exelocal
Version: cuda_10.2.89_441.22_win10.exe
Use official website pytorch: https://pytorch.org/get-started/locally/
This command in CMD: pip install torch===1.4.0 torchvision===0.5.0 -f https://download.pytorch.org/whl/torch_stable.html
In Anaconda3 I tried to use same website just change Package to conda:
Command in jupyter notebook: conda install pytorch torchvision cudatoolkit=10.1 -c pytorch
And after restart it does NOT work
So I tried to use pip again in jupyter notebook: pip install torch===1.4.0 torchvision===0.5.0 -f https://download.pytorch.org/whl/torch_stable.html
And it WORKS (if no, you can try to restart kernel):

I was getting the same error, then I found that the latest pytorch install requires CUDA 10.1, and once I installed that and the matching cuDNN, then this command line succeeded:
conda install pytorch torchvision cudatoolkit=10.1 -c pytorch

If you are using Anaconda (3.7) in windows then you need to install via .whl file.
Download .whl file from here:- https://download.pytorch.org/whl/torch_stable.html
then put in the working directory and install it using pip.
For my system, I have renamed anaconda's pip to pip37
pip37 install torch-1.5.1+cpu-cp37-cp37m-win_amd64.whl
pip37 install torchvision-0.6.1+cpu-cp37-cp37m-win_amd64.whl
It will install Torch 1.5 & Torchvision 0.6.1 in your anaconda environment

Try this code. It worked for me-
pip install torch==1.4.0+cpu torchvision==0.5.0+cpu -f https://download.pytorch.org/whl/torch_stable.html

For me (Python 3.7.6 x64 on Windows 10) this line worked:
pip install torch==1.5.0 torchvision==0.6.0 -f https://download.pytorch.org/whl/torch_stable.html

To whoever that has problem with torch installation: I think instead of following any of the commands posted here, you better first check pytorch official website (https://pytorch.org/). There you can easily specify all your setup info and get the proper command for download.

for the latest version of torch use the command below.
Without CUDA Support(CPU only):
pip install torch==1.7.0+cpu torchvision==0.8.1+cpu torchaudio===0.7.0 -f https://download.pytorch.org/whl/torch_stable.html
With CUDA Support:
pip install torch===1.7.0+cu110 torchvision===0.8.1+cu110 torchaudio===0.7.0 -f https://download.pytorch.org/whl/torch_stable.html
Check this link for the latest versions and get the command there itself from pytorch.

i got rid of this in next way: uninstall Python 32 bit and install 64bit.
Here you can find all versions
And here you can see pip/conda etc cmd commands to run to install torch

Had to fix this at two locations:
DEV windows 10 machine:
CD to C:\Program Files (x86)\Microsoft Visual Studio\Shared\Anaconda3_64\Scripts
execute: conda install pytorch
DEV Windows MSSQL Server Database Python Services
CD to C:\Program Files\Microsoft SQL Server\MSSQL14.MSSQLSERVER\PYTHON_SERVICES\Scripts
execute: pip3 install torch

Try to uninstall python 3.8 32-bit and install 64-bit. it worked for me, then:
pip3 install numpy
pip3 install --pre torch torchvision -f https://download.pytorch.org/whl/nightly/cpu/torch_nightly.html

I got the same error and fixed it with:
pip install torch===1.7.0 torchvision===0.8.1 torchaudio===0.7.0 -f https://download.pytorch.org/whl/torch_stable.html
I'm on Windows 10, Python 3.8.6.
Alternatively:
Go to https://pytorch.org/
Scroll down to the center of the page where you'll find a section with header "INSTALL PYTORCH"
Select your preferences
Copy the command to the right of where it says: "Run this Command:"
Paste it on your termminal
Click enter (I know, sounds obvious, but it wasn't for my old self when I first started)

Related

No matching distribution found for tensorflow" even though I meet the requirements [duplicate]

I installed the latest version of Python (3.6.4 64-bit) and the latest version of PyCharm (2017.3.3 64-bit). Then I installed some modules in PyCharm (Numpy, Pandas, etc), but when I tried installing Tensorflow it didn't install, and I got the error message:
Could not find a version that satisfies the requirement TensorFlow (from versions: )
No matching distribution found for TensorFlow.
Then I tried installing TensorFlow from the command prompt and I got the same error message.
I did however successfully install tflearn.
I also installed Python 2.7, but I got the same error message again. I googled the error and tried some of the things which were suggested to other people, but nothing worked (this included installing Flask).
How can I install Tensorflow? Thanks.
The latest requirements for running TensorFlow are documented in the installation documentation.
TensorFlow only supports 64-bit Python
TensorFlow only supports certain versions of Python (for example, Python 3.6 is not supported)
So, if you're using an out-of-range version of Python (older or newer) or a 32-bit version, then you'll need to use a different version.
I installed it successfully by pip install https://storage.googleapis.com/tensorflow/mac/cpu/tensorflow-1.8.0-py3-none-any.whl
There are a few important rules to install Tensorflow:
You have to install Python x64. It doesn't work with x86/32b and it gives the same error as yours.
Python versions later than 3.8 and Python 3.8 requires TensorFlow 2.2 or later. Check for supported Python versions.
For example, for TensorFlow 2.9, you can install Python3.8.6-64bit and it works like a charm. Check the latest information on the website.
if you are using anaconda, python 3.7 is installed by default, so you have to downgrade it to 3.6:
conda install python=3.6
then:
pip install tensorflow
it worked for me in Ubuntu.
I am giving it for Windows
If you are using python-3
Upgrade pip to the latest version using py -m pip install --upgrade pip
Install package using py -m pip install <package-name>
If you are using python-2
Upgrade pip to the latest version using py -2 -m pip install --upgrade pip
Install package using py -2 -m pip install <package-name>
It worked for me
Tensorflow 2.2.0 supports Python3.8
First, make sure to install Python 3.8 64bit. For some reason, the official site defaults to 32bit. Verify this using python -VV (two capital V, not W). Then continue as usual:
python -m pip install --upgrade pip
python -m pip install wheel # not necessary
python -m pip install tensorflow
As usual, make sure you have CUDA 10.1 and CuDNN installed.
Tensorflow isn't available for python 3.8 (as of Dec 4th 2019) according to their documentation page. You will have to downgrade to python 3.7.
I am using python 3.6.8, on ubunu 18.04, for me the solution was to just upgrade pip
pip install --upgrade pip
pip install tensorflow==2.1.0
Uninstalling Python and then reinstalling solved my issue and I was able to successfully install TensorFlow.
Python version is not supported
Uninstall python
https://www.python.org/downloads/release/python-362/
You should check and use the exact version in install page.
https://www.tensorflow.org/install/install_windows
python 3.6.2 or python 3.5.2 solved this issue for me
(as of Jan 1st, 2021)
Any over version 3.9.x there is no support for TensorFlow 2. If you are installing packages via pip with 3.9, you simply get a "package doesn't exist" message. After reverting to the latest 3.8.x. Thought I would drop this here, I will update when 3.9.x is working with Tensorflow 2.x
So here's the message that I got on a M1 Pro while I was executing
python -m pip install tensorflow-macos
ERROR: Could not find a version that satisfies the requirement tensorflow (from versions: none)
ERROR: No matching distribution found for tensorflow
I then re-installed python from the official source:
https://www.python.org/downloads/macos/
(Yes, as stupid as it seems.)
I then followed the Apple tutorial for Monterey:
https://developer.apple.com/metal/tensorflow-plugin/
Everything was solved by then.
Apple Silicon (M1+ Chip)
If you are using a Mac with an M1 chip or higher, you need to install Tensorflow metal plugin for compatability with your architecture.
Simple installation instructions for Tensor Flow are found on Apple's website: https://developer.apple.com/metal/tensorflow-plugin
Looks like the problem is with Python 3.8. Use Python 3.7 instead. Steps I took to solve this.
Created a python 3.7 environment with conda
List item Installed rasa using pip install rasa within the environment.
Worked for me.
Running this before the tensorflow installation solved it for me:
pip install "pip>=19"
As the tensorflow's system requirements states:
pip 19.0 or later
For version TensorFlow 2.2:
Make sure you have python 3.8
try:
python --version
or
python3 --version
or
py --version
Upgrade the pip of the python which has version 3.8
try:
python3 -m pip install --upgrade pip
or
python -m pip install --upgrade pip
or
py -m pip install --upgrade pip
Install TensorFlow:
try:
python3 -m pip install TensorFlow
or python -m pip install TensorFlow
or py -m pip install TensorFlow
Make sure to run the file with the correct python:
try:
python3 file.py
or python file.py
or py file.py
1.Go to https://www.tensorflow.org/install/pip website and look if the version you are using support the Tensorflow. some latest version does not support Tesnsorflow. until Tensorflow releases its latest version for that Python version.
you must have 64 bit python installed
have latest version of pip installed
pip install --upgrade pip
using pip install tensorflow --user did it for me
I had this problem on my macOS (with M1 Pro) even with the latest 64-bit Python and the latest pip installed. This is how I've solved it. Try to run:
pip install tensorflow-macos
If you will get the error ending like this (like I did)...
...
raise ReadTimeoutError(self._pool, None, "Read timed out.")
pip._vendor.urllib3.exceptions.ReadTimeoutError: HTTPSConnectionPool(host='files.pythonhosted.org', port=443): Read timed out.
...then simply run:
pip install --default-timeout=100 tensorflow-macos
Tensorflow seems to need special versions of tools and libs.
Pip only takes care of python version.
To handle this in a professional way (means it save tremendos time for me and others)
you have to set a special environment for each software like this.
An advanced tool for this is conda.
I installed Tensorflow with this commands:
sudo apt install python3
sudo update-alternatives --install /usr/bin/python python /usr/bin/python3 1
sudo apt install python3-pip
sudo apt-get install curl
curl https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh > Miniconda3-latest-Linux-x86_64.sh
bash Miniconda3-latest-Linux-x86_64.sh
yes
source ~/.bashrc
installs its own phyton etc
nano .bashrc
maybe insert here your proxies etc.
conda create --name your_name python=3
conda activate your_name
conda install -c conda-forge tensorflow
check everything went well
python -c "import tensorflow as tf; tf.enable_eager_execution(); print(tf.reduce_sum(tf.random_normal([1000, 1000])))"
PS: some commands that may be helpful
conda search tensorflow
https://www.tensorflow.org/install/pip
uses virtualenv. Conda is more capable. Miniconda ist sufficient; the full conda
is not necessary
use python version 3.6 or 3.7 but the important thing is you should install the python version of 64-bit.
In case you are using Docker, make sure you have
FROM python:x.y.z
instead of
FROM python:x.y.z-alpine.
This issue also happens with other libraries such as matplotlib(which doesn't support Python > 3.9 for some functions) let's just use COLAB.
Slightly different issue for me but I will still post an answer here. tensorflow package is working, but not tflite-runtime.
pip install --extra-index-url https://google-coral.github.io/py-repo/ tflite-runtime==2.5.0
I solved the same problem with python 3.7 by installing one by one all the packages required
Here are the steps:
Install the package
See the error message:
couldn't find a version that satisfies the requirement -- the name of the module required
Install the module required.
Very often, installation of the required module requires the installation of another module, and another module - a couple of the others and so on.
This way I installed more than 30 packages and it helped. Now I have tensorflow of the latest version in Python 3.7 and didn't have to downgrade the kernel.

Why does pip install not work for catboost?

I have to install catboost but can not make it by pip install catboost.
There is not catboost library in Anaconda, so pip in the one way.
The error message is:
Could not find a version that satisfies the requirement catboost <for version: >
No matching distribution found for catboost.
Python version is 3.6.3.
Screenshot of error:
error message
I've tried :
pip install catboost==0.12.2
pip install catboost==0.12.1.1
pip install catboost==0.12.1
pip install catboost==0.12.0
and
pip install catboost==0.11.0
pip install catboost==0.10.2
None of these works.
Why does this problem appeared and is there another way to install catboost?
From the docs
Installation is only supported by the 64-bit version of Python.
You need to reinstall the 64 bit version of python to use the cat boost package
I had the same problem but it was mainly related to Docker because the error was only occurring when I was trying to install it through a docker - it turned out there is something related to M1 Apple architecture and the solution was to modify the docker command as following
docker buildx build --platform=linux/amd64 -t ${IMAGE_TAG} -f Dockerfile
For me the issue was I was developing on an M1 Mac. Trying to install as root, using conda and using docker images were all unsuccessful.
The fix I found was using the amd64 docker image as my base. The dockerfile code was:
FROM amd64/python:3.9-buster
RUN pip install -U pip
RUN pip install --upgrade setuptools
RUN pip install catboost
Can't exactly remember how I arrived at the above code, but thanks to https://github.com/prabodh1194 for putting this together. A dockerfile with this code can be found here (as of 25NOV2021) https://github.com/prabodh1194/docker_images/blob/main/catboost/0.26/Dockerfile
in my case, a virtual environment was using an old version of pip and a simple upgrade of pip worked!
python3 -m pip install --upgrade pip

How do I install the "sparse_dot_topn" Package in Anaconda Installer?

I am trying to install the "sparse_dot_topn" package in Alibaba Cloud ECS instance. Firstly I tried to install it through the Anaconda installer.
conda install sparse_dot_topn
It throws like there is no package available
So I tried to install via pip
Pip install spare_dot_topn
But it throws me the following error
What am I missing? Please leave your suggestions
sparse_dot_topn requires Cython, try installing it this way:
pip install cython
pip install git+https://github.com/ing-bank/sparse_dot_topn.git
I have tried it first with pip install and failed. Then I tried within Anaconda terminal with the following comment and it was succesfull.
conda install -c conda-forge sparse_dot_topn

install Tensorflow 1.0 on windows by Anaconda error

By following the instructions on Tensorflow website, I tried to install cpu-only version Tensorflow by Anaconda. However, the 4th step
(tensorflow)C:> pip install --ignore-installed --upgrade https://storage.googleapis.com/tensorflow/windows/cpu/tensorflow-1.0.0-cp35-cp35m-win_x86_64.whl
outputs an error:
tensorflow-1.0.0-cp35-cp35m-win_x86_64.whl is not a supported wheel on this platform. Could anyone tell me the reason behind this?
The command on the website is currently wrong. Replace x86_64 at the end of the URL with amd64 to get the correct command:
pip install --ignore-installed --upgrade https://storage.googleapis.com/tensorflow/windows/cpu/tensorflow-1.0.0-cp35-cp35m-win_amd64.whl
Alternatively you can use the following simpler command to install the latest CPU version:
pip install --ignore-installed --upgrade tensorflow
I think your problems could be one of this:
your python version is not Python3.5
Your system is not x64 windows.
So you can change install method below.
You can install tensorflow with pip direct like this:
pip install tensorflow
but this works only pip version > 9,
if you're using pip version under 9, you have to upgrade pip first.
you can upgrade your pip with this:
pip install -U pip
if you've installed python for all user, you might run this code with administrator account.

ImportError: No module named xgboost

When I tried import from python terminal I get this error, although I followed all the steps to install xgboost, somehow python is unable to get the package details.I am relatively new to python, I could easily install numpy and pandas packages,I used this link for installation on MACOSX http://xgboost.readthedocs.io/en/latest/build.html
>>> import xgboost
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named xgboost
When I did pip install xgboost, I am getting this error,
Command "python setup.py egg_info" failed with error code 1 in /private/var/folders/h7/pyph_7qj6171tqp50cf2xc7m0000gn/T/pip-build-TEvbD6/xgboost/
I am getting this on printing sys path,
print sys.path
['', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python27.zip', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-darwin', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac/lib-scriptpackages', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-old', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload', '/Library/Python/2.7/site-packages', '/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python', '/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/PyObjC']
First you need to get control of your python environment. Download the homebrew python by pasting these into a fresh terminal window
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
here you will be prompterd to enter your password. After homebrew is installed, install python with brew install python. Please check your installation with brew doctor and follow homebrew's suggestions.
Now, with a fresh terminal window, install xgboost from pip. Open terminal and paste this in:
pip install xgboost
I had the same issue. I tried everything but the only solution that worked for me to was to install the whl file directly from here :
http://www.lfd.uci.edu/~gohlke/pythonlibs/#xgboost
then you can do :
pip install yourFile.whl
On windows I managed to just double click on the whl file and install it
Good luck
FYI if you are using anaconda dist'n then need to do
conda install -c conda-forge xgboost
Use conda install in Anaconda Powershell Prompt then use pip install
conda install -c conda-forge xgboost
pip install xgboost
git clone --recursive https://github.com/dmlc/xgboost
cd xgboost
sudo cp make/minimum.mk ./config.mk;
sudo make -j4;
sh build.sh
cd python-package
python setup.py install
Atleast Now I can import xgboost from terminal on macosx, I haven't been able to import it in jupyter notebook as yet.
Try running
pip install xgboost
in Anaconda prompt; it's important that you do it in Anaconda prompt so it is in same location as the Python you're using.
I tried
pip install xgboost
and
pip3 install xgboost
But it doesn't work
ModuleNotFoundError: No module named 'xgboost'
Finally I solved
Try this in the Jupyter Notebook cell
import sys
!{sys.executable} -m pip install xgboost
Results:
Collecting xgboost
Using cached xgboost-1.4.1-py3-none-win_amd64.whl (97.8 MB)
Requirement already satisfied: scipy in c:\programdata\anaconda3\lib\site-packages (from xgboost) (1.5.2)
Requirement already satisfied: numpy in c:\programdata\anaconda3\lib\site-packages (from xgboost) (1.19.2)
Installing collected packages: xgboost
Successfully installed xgboost-1.4.1
Write this on the terminal of Jupyter:
conda install -c anaconda py-xgboost
On Pycharm you can go to Pycharm > Prefernces, go to the interpreter you have and install the xgboost package.
Give the following commands a try.
pip install xgboost
pip install plotly
All you need within Jupyter Notebook cell is:
try running
import sys
!{sys.executable} -m pip install xgboost
Open the terminal
Type pip install xgboost and hit enter.
Make sure your internet connection is good.
Do not forget to crosscheck the successful installation of it in jupyter.
for ubuntu 18 LTS, this worked for me.
cmake is a pre-requiste to it, so if you havent you would need to install that, currently at print its version 3.10 + minimum.
in terminal:
sudo snap install cmake --classic
in jupyter notebook(if terminal just edit it)
import sys
!{sys.executable} -m pip install xgboost
if you run
pip install xgboost
in command line and no result, run the same command in jupyter notebook.
In my case, I had multiple Python versions, and I was installing it in the wrong one.
pip install xgboost
installed the module on Python 3.7, but I needed to install it with Python 3.10. What I run was:
py -m pip install xgboost
which worked, since "py" is my binary for Python 3.10. The suitable command if you have multiple Python versions may be different depending on which version you have. In Ubuntu, for example, this worked for me:
python3.8 -m pip3 install xgboost
Windows 10, Run Anaconda as Administrator.
Launch Powershell Prompt from Navigator
pip install xgboost

Categories

Resources