Cannot uninstall numpy 1.21.2, RECORD file not found - numpy

I encountered a problem while installing
pip install pytorch-nlp
The erro is as follow:
ERROR: Could n`ot install packages due to an OSError: [Errno 2] No such file or directory: 'c:\\users\\pcpcpc\\anaconda3\\envs\\pytorch\\lib\\site-packages\\numpy-1.21`.2.dist-info\\METADATA'
SO I tried to reinstall numpy by
pip install --force-reinstall --no-deps numpy==1.21.2
But I get the error:
ERROR: Cannot uninstall numpy 1.21.2, RECORD file not found. You might be able to recover from this via: 'pip install --force-reinstall --no-deps numpy==1.21.2'.

As #Phoenix suggested, you might have an incomplete installation of numpy in your site-packages folder.
Find your site-packages folder.
SITE_PACKAGES_FOLDER=$(python3 -c "import sysconfig; print(sysconfig.get_paths()['purelib'])")
echo $SITE_PACKAGES_FOLDER
Check for extraneous numpy packages from your site-packages folder.
ls $SITE_PACKAGES_FOLDER/numpy*
Trash extraneous packages.
pip install trash-cli
trash $SITE_PACKAGES_FOLDER/numpy*
Reinstall numpy.
pip install --upgrade numpy

Try manually deleting the numpy files/directories and then do
pip install --upgrade --force-reinstall <package>
One way to find the numpy files is to run
python -c "import numpy; print(numpy.__file__)"
For example, this prints out
/home/tink-user/workspace/.conda_envs/tink-payment-categorization/lib/python3.7/site-packages/numpy/__init__.py
for me. So you can go there:
cd /home/tink-user/workspace/.conda_envs/tink-payment-categorization/lib/python3.7/site-packages
then you can check with something like this to see which numpys are there:
ls numpy*
ls | grep numpy
Delete the numpy directories and try force reinstalling (pip install --upgrade --force-reinstall <package>).
Conda
This also happened to me in a conda environment after I ended up with multiple numpy installations and tried to manually delete them by removing the directories in site-packages. I had to force reinstall with conda (I think after manually deleting the directories for numpy): conda install numpy --force-reinstall.

None of the above solutions worked for me
What worked for me:
Delete that particular folder from the site-packages
Only delete the folder with the version number and not the folder that has python modules and files
Delete that folder with metadata files matching the numpy version in the warning and error message in the installation traceback
re-install the package
pip install numpy just as you would do
this work for both cases
global environment
local or project related environment
** else you will have delete that environment and create a new one **

Related

Cannot pip udate numpy

I want to update numpy from 1.19.1 to 1.19.2. So I did the following command:
pip install --upgrade numpy
However, I received the following error message:
ERROR: Could not install packages due to an EnvironmentError: [Errno 2] No such file or directory: '/userdata/data-dlin/.conda/envs/mybase/lib/python3.7/site-packages/numpy-1.19.1.dist-info/RECORD'
I went to the directory and found the RECORD file was indeed missing. How do I fix the error?
Uninstalling numpy (pip uninstall numpy), then deleting the entire folder
(python environment)/lib/site-packages/numpy-1.19.X.dist-info
And reinstalling numpy (pip install numpy) fixed it for me.

No module named tensorflow even after installing with pip

I'm trying to follow this guide to test this new algorithm: https://github.com/lalonderodney/SegCaps
I can't do it in my PC, so i'm using another server with Putty. Now I'm connected with the other server.
First of all I installed TensorFlow as indicates in the guide with :
pip install -r requirements.txt
After I wrote this code: ./main.py segcaps.png
in which segcaps.png is the image that i want to use
Finally I wrote python main.py --data_root_dir data
that is the only required parameter with the directory containing imgs and masks folders.
Now it gives me an error:
ModuleNotFoundError: No module named 'tensorflow.python.framework'
I searched it in the directory tensorflow/python/framework and it exists.
So, i don't know how to solve it. Ideas?
If you have multiple Python versions installed, then you'll (most likely) have multiple pip versions installed too. Make sure that the pip command you use installs the package(s) into the Python version you want it to. It may so happen that the package got installed into python2 but you wanted it in python3.
Since using pip did not install the packages in python3, pip3 is most likely to the PyPI for python3. Try
pip3 install -r requirements.txt
and that should work.
In case you have an EnvironmentError you can try this (bad idea):
pip3 install -r requirements.txt --user
This solves the problem most of the times on standalone machines. I'm not sure about the server; insufficient permissions might block this.
Why is the --user flag a bad idea? Read: What is the purpose “pip install --user …”?
You can use pip show tensorflow to see if it is installed or not.
As for ModuleNotFoundError try uninstalling keras and reinstalling an earlier version by pip install keras==2.1.6

uninstall virtualenv in mac

I try to install tensorflow via virtualenv in mac, the reference is here:
for I have python already, so I install virtualenv by:
sudo pip install --upgrade virtualenv
build a new virtualenv environment in ~/development project/tensorflow, not in ~/tensorflow as is said in the reference:
virtualenv --system-site-packages ~/development project/tensorflow
cd ~/development project/tensorflow
active virtualenv by:
source bin/activate # if use bash,and I choose this line to run
when I am in virtualenv and run this:
(tensorflow)$ pip install --upgrade <$url_to_binary.whl>
it comes out an error:
zsh: parse error near '\n'
then I check here to help solve it
it says that <$url_to_binary.whl> should be replaced by https://storage.googleapis.com/tensorflow/mac/tensorflow-0.5.0-py2-none-any.whl, and I do so. And problem gone.
but, when I try to test tensorflow by cd some dir in tensorflow like:
(tensorflow)$ cd tensorflow/models/image/mnist
the dir is not exist.
so I guess the url I modified cause it, and I try to reinstall virtualenv and tensorflow, to make my install clean.
tensorflow is successfully uninstalled, but when I remove virtualenv, it booms:
Exception: Traceback (most recent call last): File
"/usr/local/lib/python2.7/site-packages/pip/basecommand.py", line 215,
in main
status = self.run(options, args) File "/usr/local/lib/python2.7/site-packages/pip/commands/uninstall.py",
line 76, in run
requirement_set.uninstall(auto_confirm=options.yes) File "/usr/local/lib/python2.7/site-packages/pip/req/req_set.py", line 346,
in uninstall
req.uninstall(auto_confirm=auto_confirm) File "/usr/local/lib/python2.7/site-packages/pip/req/req_install.py", line
754, in uninstall
paths_to_remove.remove(auto_confirm) File "/usr/local/lib/python2.7/site-packages/pip/req/req_uninstall.py",
line 115, in remove
renames(path, new_path) File "/usr/local/lib/python2.7/site-packages/pip/utils/init.py", line
267, in renames
shutil.move(old, new) File "/usr/local/Cellar/python/2.7.12_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py",
line 303, in move
os.unlink(src) OSError: [Errno 13] Permission denied: '/usr/local/lib/python2.7/site-packages/virtualenv-15.1.0.dist-info/DESCRIPTION.rst'
I delete dir tensorflow
for now I could not uninstall virtualenv neither install it, but it still exist....that's really wired.
If I run sudo pip install --upgrade virtualenv again, it says:
The directory '/Users/Calvino/Library/Caches/pip/http' or its parent
directory is not owned by the current user and the cache has been
disabled. Please check the permissions and owner of that directory. If
executing pip with sudo, you may want sudo's -H flag. The directory
'/Users/Calvino/Library/Caches/pip' or its parent directory is not
owned by the current user and caching wheels has been disabled. check
the permissions and owner of that directory. If executing pip with
sudo, you may want sudo's -H flag. Requirement already up-to-date:
virtualenv in /usr/local/lib/python2.7/site-packages
My question is that how could I remove virtualenv and tensorflow thoroughly and reinstall them.
I would be very appreciate if anyone could help.
have been two years but anyways yo need to uninstall with >
//Reinstal python 2 or 3 with new SO update
brew update
sudo installer -pkg /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg -target /
brew reinstall python#3
Reference
then reinstall tensorflow with>
https://www.tensorflow.org/install/pip
Now, you just need to run:
(tensorflow)$ pip install --upgrade tensorflow # for Python 2.7
(tensorflow)$ pip3 install --upgrade tensorflow # for Python 3.n
And remove by: (this is for virtualenv, you change the path, following path also should be changed to ~/development/project/tensorflow)
$ rm -r ~/tensorflow
If you install tensorflow with native pip:
$ pip uninstall tensorflow
$ pip3 uninstall tensorflow
More information: https://www.tensorflow.org/install/install_mac

Tensorflow installation error

I am trying to install tensorflow with virtualenv
I have successfully went through the first 5 steps but on the 5th
pip install --upgrade tensorflow
I am getting an error
Found existing installation: numpy 1.8.0rc1
DEPRECATION: Uninstalling a distutils installed project (numpy) has been deprecated and will be removed in a future version. This is due to the fact that uninstalling a distutils project will only partially uninstall the project.
Uninstalling numpy-1.8.0rc1:
OSError: [Errno 1] Operation not permitted: '/tmp/pip-Z5MKQS-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/numpy-1.8.0rc1-py2.7.egg-info'
You might be installing globally try adding sudo
sudo pip install --upgrade tensorflow
Otherwise just upgrade numpy separately with sudo and then you can try to install tensorflow locally.
I have no idea why you have that error.
But you can try with first installing pip3 and then try install with pip3 as
pip3 install --upgrade tensorflow
This will help you.

PIP install pandas not working

I am trying to install pandas with .whl file in a work computer but I get " cannot fetch URL" error. I have up to date version of PIP installed.How can I get this to work.I'm using Python 3.5.Any help will be appreciated.
I just used the following which was quite simple. First open a console then cd to where you've downloaded your file like some-package.whl and use
pip install some-package.whl
python -m pip install some-package.whl also works if pip is not found in PATH
Note: if pip.exe is not recognized, you may find it in the "Scripts" directory from where python has been installed. If pip is not installed, this page can help:
How do I install pip on Windows?
Note: for clarification
If you copy the *.whl file to your local drive (ex. C:\some-dir\some-file.whl) use the following command line parameters --
pip install C:/some-dir/some-file.whl
I guess since you are on a work computer
try this
sudo pip --proxy=http://username:password#proxyURL:portNumber install yolk
for example:
sudo pip --proxy=http://202.194.64.89:8000 install elasticsearch
202.194.64.89:8000 is my PROXY,