Problem installing tensorflow in virtual environment - python

This issue in some form has come up before, however I am having a variant of this issue.
I had python 3.8 installed. Tensorflow does not have a version for this python.
I therefore installed python 3.7 and set up a virtual environment using virtualenv.
In visual studio code I even updated the settings json "python.pythonPath": to the correct path for version 3.7 of python.
I install the correct version of tensorflow using the correct link for 3.7 on the site:
'''pip install --upgrade https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow_cpu-2.1.0-cp37-cp37m-manylinux2010_x86_64.whl'''
But i still get the error
"ERROR: tensorflow_cpu-2.1.0-cp37-cp37m-win_amd64.whl is not a supported wheel on this platform."
When i type python -V I still get Python 3.8.1, could this mean I am not correctly using the virtual environment?
However I have now set up virtual environment using anaconda which is limited to 3.7 and it still says 3.8 when using "python -V" and i get the same error when trying to install.

You can try to either reinstall anaconda, visual studio, or type in the command "pip install --upgrade tensorflow". This should work without the link.

After creating the virtual environment you need to activate it if you haven't already. Once you do, your command line prompt should indicate that a new version of Python, in your case 3.7 is now running.

I ended up using Anaconda with Python 3.6, it seems tensorflow would not work for 3.7 on windows.

Related

Does "pipenv install requests" work with python 3.9.2?

I am following a guide to get NLTK working on my computer and part of the process is setting up a virtual environment so I can manage packages across projects.
Here is the guide I'm following: https://docs.python-guide.org/dev/virtualenvs/
I run into an issue when I reach the part where I'm supposed to "pipenv install requests". I get the message Installing...Failed to load paths: No Python at 'c:\users\[username]\appdata\local\programs\python\**python38**\python.exe'
I have python 3.9.2 installed so my path is c:\users\[username]\appdata\local\programs\python\**python39**\python.exe. Therefore, the python38 directory does not exist, nor does the path in my environment variables.
Do I need to install 3.8.8 to be able to follow this guide? If so, can I install 3.8.8 while 3.9.2 is installed as well, or Can I switch between the two versions? should I just uninstall 3.9.2 and work with 3.8.8?
Thank you.
You might need to specify a python version for pipenv, you can do that with: pipenv --version 3.9, you can read more about specifying the version here: https://pipenv.pypa.io/en/latest/basics/#specifying-versions-of-python

Unable to start jupyter notebook in visual studio code

I am trying to make a jupyter notebook in visual studio code but I keep getting this:
''Unable to start session for kernel Python 3.8.3 64-bit ('Lenovo':
virtualenv). Select another kernel to launch with.''
I have anaconda installed and the jupyter notebook works fine in the anaconda navigator. I also tried to use python 3.8.3 base:'conda' but it didnt work. I'm using windows 10
This issue also occurs on my computer. The solution is to restore the version number of a dependency package "traitlets" of ipython kernel to 4.3.3.
You could try to use "pip list" to view the version of the module "traitlets" in the current virtual environment. If it shows version 5.0, it is recommended that you use version 4.3.3.
You could reinstall "traitlets 4.3.3" with the following command:
python -m pip install 'traitlets==4.3.3' --force-reinstall
If this command is not available, you could use 'pip' to uninstall traitlets5.0 (pip uninstall traitlets) and then use 'pip' to install traitlets4.3.3.(pip install traitlets==4.3.3)
Reference: Unable to start session for kernel Python.
I had the exact same problem. Fix it by uninstalling the Python extension that is linked to that error message.
If you are using conda to manage your Python environments, activate your target environment at a command prompt, then enter the following:
$ conda install traitlets=4.3.3
This solved the problem for me.

`pip` installed `discord.py` to `1.3.4` successfully, but `print(discord.__version__)` displays `1.3.3`

I ran the command pip install discord.py==1.3.4 successfully. However when I ran print(discord.__version__) in PyCharm it displayed 1.3.3. My pip version is 20.1.1 and Python is version 3.7. Does anyone have any idea why the version number is different?
Make sure you are not using virtual environment. You may have installed the latest version to your system packages. Be sure to also install it in your dev environment.

Could not find a version that satisfies the requirement torch>=1.0.0?

Could not find a version that satisfies the requirement torch>=1.0.0
No matching distribution found for torch>=1.0.0 (from stanfordnlp)
This can also happen if your Python version is too new. Pytorch currently does not support past 3.7.9.
Figured out from: https://stackoverflow.com/a/58902298/5090928
This is the latest command for pytorch.
pip install torch===1.4.0 torchvision===0.5.0 -f https://download.pytorch.org/whl/torch_stable.html
I had some difficulties with this as well. The steps I had to do was:
Install the latest version of PyTorch:
pip3 install torch===1.3.1 torchvision===0.4.2 -f
https://download.pytorch.org/whl/torch_stable.html
Make sure you are installing with 64bit python version; otherwise, it won't work
I finally managed to solve this problem thanks to John Red' comment and serg06 answer. Here's what I've done :
Install Python 3.7.9 and not newer.
BUT make sure to install 64bits python
Every other combination failed for me.
I had this same issue while installing standfordnlp in my windows 10 system.
Installing torch before installing stanfordnlp worked out for me.
I have installed torch from pytorch official website.
Use 64-Bit Python. PyTorch doesn't work with 32-Bit Python. I had the same issue.
For people visiting this questions with slightly newer versions of python and pytorch, I had Python 3.8.3 32-bit and even though the pytorch page states that:
Currently, PyTorch on Windows only supports Python 3.7-3.9;
Installing Python 3.9.13 64-bit instead of Python 3.8.3 32-bit solved it for me.
After that, I used the install script generator and ran
python -m pip install torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/cu113
... and it started downloading.
If you have python 3.7 already installed along with newer versions then can use below command to install torch using python 3.7
py -3.7 -m pip install torch
But also note that you have to execute the python program using py -3.7
py -3.7 program_name.py
torch and torchvision need python 3.8.x ... so in your CLI run
python --version
to get the python version.
make sure that your environment has python 3.8.x, otherwise, create another virtual environment with anaconda
conda create -n myenv python==3.8 anaconda
conda activate myenv
Then install torch and torchvision by this command
pip install torch===1.5.0 torchvision===0.6.0 -f https://download.pytorch.org/whl/torch_stable.html
I went heaven and earth for this problem and here is what it turned out to be:
1- i had python 3.10
2- the python.exe in my virtual environemnt linked to python310
i uninstalled the python3.10 , then went to delete the paths in system environemnts variables (go to windows search, type this thing, you get a window, click on environment variables, and find a word called paths, click edit) ....\python310\ (i named as such when initially installed, you probs have another name) and also this ...python310\Scripts\
delete them
go to https://www.python.org/downloads/release/python-3711/ , istall pythion 3.7 , after that go back to system env. variables thingy, .. add the paths that ends with ...\python37\ , and ...\python37\Scripts\ (make you sure you end the paths with "")
then go to new command prompt, type python , you should get Python 3.7.0 ...
cd to your virtual environment path script (mine looked like this C:\Users...\python_ver\python_projects\root_environment\Scripts>) , activate to the name of whatever you called, for me i typed: activate tf.
type python again, if you have python 3.7 as a result, you good to go ... if you still seeing python 3.10 ... then you probs get some error saying no python in ....\python310\python.exe ... so:
go the folder that you saved python310 (the path shown in the last step), make sure all folders of your python 3.7 go in there.
type python in cmd in the same virtual envrioment path by the cursor ... to check you running pythong 3.7 ...
once python 3.7 is your default .. run the blood Clot for pytorch https://pytorch.org/ to install pytorch
thanks to all the guys on this
I tried every possible command for Windows, but nothing worked. I also tried using Pycharm package installation, everything throws the same error.
Finally installed Pytorch using Anaconda.
For previous versions please use the snippets from the PyTorch website; https://pytorch.org/get-started/previous-versions/
As an example, this will turn into an error since the cudatoolkit versions are not listed in pip;
!pip install torch==1.10.0+cu111
ERROR: Could not find a version that satisfies the requirement torch==1.10.0+cu111 (from versions: 1.0.0, 1.0.1, 1.0.1.post2, 1.1.0, 1.2.0, 1.3.0, 1.3.1, 1.4.0, 1.5.0, 1.5.1, 1.6.0, 1.7.0, 1.7.1, 1.8.0, 1.8.1, 1.9.0, 1.9.1, 1.10.0, 1.10.1, 1.10.2, 1.11.0) ERROR: No matching distribution found for torch==1.10.0+cu111
For the same Torch version and cudatoolkit, you can use the following code instead;
!pip install torch==1.10.0+cu111 torchvision==0.11.0+cu111 torchaudio==0.10.0 -f https://download.pytorch.org/whl/torch_stable.html
import torch
TORCH_VERSION = ".".join(torch.__version__.split(".")[:2])
CUDA_VERSION = torch.__version__.split("+")[-1]
print("torch: ", TORCH_VERSION, "; cuda: ", CUDA_VERSION)
Result:
torch: 1.10 ; cuda: cu111
I want to pip install " torch>=1.4.0, torchvision>=0.5.0 ", but in a conda env with python=3.0, this is not right.
I tried create a new conda env with python=3.7, and pip install " torch>=1.4.0, torchvision>=0.5.0 " again, it is ok.
This is for Deep Reinforcement Learning: Chapter-6: 02_dnq_pong.py:
I did not verify the above solutions. I found it tedious to change the existing library version.
So, as mentioned by someone in GIT, you just have to change two variables in your loss function.
https://github.com/PacktPublishing/Deep-Reinforcement-Learning-Hands-On/issues/90
Change the variables to below:
actions_v = torch.tensor(actions).to(device, dtype=torch.int64)
done_mask = torch.tensor(dones).to(device, dtype=torch.bool)
You could make similar changes to the variables which cause the error, in your respective programs.
I had the same issue with Python 3.8.2 which is currently supported by PyTorch. I updated pip from version 19.2.3 to 22.3.1 and my issue was solved:
pip install --upgrade pip
Use a virtual environment with Python 3.7.9
Go to the python version download page (with binary installers) https://www.python.org/downloads/release/python-379/
Go to that page and download Windows x86-64 embeddable zip file
extracted the zip file and placed the contents inside the project folder.
Then used,
virtualenv --python .\python379\python.exe env
To create the virtual environment by specifying the exe location.
Now activate it using .\env\Scripts\activate and you should be able to install.
If you get any error like virtualenv: The term 'virtualenv' is not recognized as a name of a cmdlet, uninstall virtualenv using pip uninstall virtualenv, close the terminal, open terminal as
Administrator / root user and install again.
follow the link: https://pytorch.org/
and set your system requirement in QUICK START LOCALLY SECTION

import h2o fails on anaconda cmd but works on windows cmd ?

I have successfully installed h2o package using pip. But I am having a weird problem when I try to import it using windows cmd it works well but it fails when I try to do it through anaconda prompt command, jyputer or Spyder ? I tried to restart them and run the command but still having the same problem.
See this screenshoot below :
The problem that you are encountering is due to having multiple python versions on your machine, which is clearly visible in the screenshot. The default python version is not Anaconda python. After installing H2O using pip, it's not visible to python version installed via Anaconda distribution. There are a few options to solve this issue
Install H2O using anaconda pip (from anaconda terminal)
Install H2O using conda installer conda install -c anaconda h2o, which will install H2O version 3.18 from Anaconda channel
Install directly from a channel maintained by H2O - conda install -c h2oai h2o, which is the up to date version of the library.
In addition, I would recommend correctly setting up environment variables and python path. Otherwise, it will become difficult to manage all of the packages and keep track which pip was used to install which package. Please see the following link for a discussion on how to add anaconda python to PYTHONPATH on a windows machine
https://docs.python.org/3/using/windows.html#excursus-setting-environment-variables

Categories