I have downloaded, built and installed the sample pypi project. The project is supposed to be used to give an insight to python packaging and is referenced in Python Packaging User Guide and Packaging and Distributing Projects. I am therefore confused to why on earth following their instructions on creating the package I have an error when uninstalling it.
As mentioned above I have used their sample project. If anyone can shed some light it would be appreciated.
Key notes: I am running Mac OSX, my installed python version is 3.5.1
Below are steps to reproduce the problem:
mkdir testdirectory
cd testdirectory/
pyvenv venv # Creating a virtual environment
source venv/bin/activate
git clone https://github.com/pypa/sampleproject.git # Getting sample project
cd sampleproject/
python setup.py build
python setup.py install # Installing on the virtual environment
pip list
peppercorn (0.5)
pip (7.1.2)
sample (1.2.0)
setuptools (18.2)
pip uninstall sample
Resulting in the following output:
Uninstalling sample-1.2.0:
/Users/steve/testdirectory/venv/bin/sample
/Users/steve/testdirectory/venv/lib/python3.5/site-packages/sample-1.2.0-py3.5.egg
Proceed (y/n)? y
Successfully uninstalled sample-1.2.0
Traceback (most recent call last):
File "/Users/steve/testdirectory/venv/bin/pip3", line 11, in <module>
sys.exit(main())
File "/Users/steve/testdirectory/venv/lib/python3.5/site-packages/pip/__init__.py", line 217, in main
return command.main(cmd_args)
File "/Users/steve/testdirectory/venv/lib/python3.5/site-packages/pip/basecommand.py", line 248, in main
pip_version_check(session)
File "/Users/steve/testdirectory/venv/lib/python3.5/site-packages/pip/utils/outdated.py", line 102, in pip_version_check
installed_version = get_installed_version("pip")
File "/Users/steve/testdirectory/venv/lib/python3.5/site-packages/pip/utils/__init__.py", line 858, in get_installed_version
working_set = pkg_resources.WorkingSet()
File "/Users/steve/testdirectory/venv/lib/python3.5/site-packages/pip/_vendor/pkg_resources/__init__.py", line 629, in __init__
self.add_entry(entry)
File "/Users/steve/testdirectory/venv/lib/python3.5/site-packages/pip/_vendor/pkg_resources/__init__.py", line 685, in add_entry
for dist in find_distributions(entry, True):
File "/Users/steve/testdirectory/venv/lib/python3.5/site-packages/pip/_vendor/pkg_resources/__init__.py", line 2075, in find_eggs_in_zip
if metadata.has_metadata('PKG-INFO'):
File "/Users/steve/testdirectory/venv/lib/python3.5/site-packages/pip/_vendor/pkg_resources/__init__.py", line 1605, in has_metadata
return self.egg_info and self._has(self._fn(self.egg_info, name))
File "/Users/steve/testdirectory/venv/lib/python3.5/site-packages/pip/_vendor/pkg_resources/__init__.py", line 1963, in _has
return zip_path in self.zipinfo or zip_path in self._index()
File "/Users/steve/testdirectory/venv/lib/python3.5/site-packages/pip/_vendor/pkg_resources/__init__.py", line 1843, in zipinfo
return self._zip_manifests.load(self.loader.archive)
File "/Users/steve/testdirectory/venv/lib/python3.5/site-packages/pip/_vendor/pkg_resources/__init__.py", line 1783, in load
mtime = os.stat(path).st_mtime
FileNotFoundError: [Errno 2] No such file or directory: '/Users/steve/testdirectory/venv/lib/python3.5/site-packages/sample-1.2.0-py3.5.egg'
It appears that the package has uninstalled correctly however the error is still thrown.
This is documented:
$ pip help uninstall
Usage:
pip uninstall [options] <package> ...
pip uninstall [options] -r <requirements file> ...
Description:
Uninstall packages.
pip is able to uninstall most installed packages. Known exceptions are:
- Pure distutils packages installed with ``python setup.py install``, which
leave behind no metadata to determine what files were installed.
- Script wrappers installed by ``python setup.py develop``.
i.e. you are getting the error because you didn't use pip itself to install - you used setup.py and so pip doesn't know what was installed.
Install package not with python setup.py install but with pip install .
Then uninstalling will work without errors
Related
Hi I'm a beginner of python, I don't remember when and how I installed python3.8 on my Macbook air, only knew the installed path:
% which python
/usr/bin/python
% which python3
/usr/local/bin/python3
The pip command cannot not be found but pip3 is ok. Today I want to install virtaulenv:
% sudo -H pip3 install virtualenv
WARNING: Ignoring invalid distribution - (/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages)
Successfully installed virtualenv-20.6.0
I can use "pip3 show virtualenv" to know the info:
% pip3 show virtualenv
Name: virtualenv
Version: 20.6.0
Summary: Virtual Python Environment builder
Home-page: https://virtualenv.pypa.io/
Author: Bernat Gabor
Author-email: gaborjbernat#gmail.com
License: MIT
Location: /Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages
Requires: six, platformdirs, backports.entry-points-selectable, distlib, filelock
Required-by:
But when I use "virtualenv" I got command not found message then I "pip3 uninstall" it. I searched for this and got a tip to use "easy_install" to install virtualenv. After installed I can execute the command, but got some error message:
% virtualenv
Traceback (most recent call last):
File "/usr/local/bin/virtualenv", line 6, in <module>
from pkg_resources import load_entry_point
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources/__init__.py", line 3241, in <module>
#_call_aside
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources/__init__.py", line 3225, in _call_aside
f(*args, **kwargs)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources/__init__.py", line 3254, in _initialize_master_working_set
working_set = WorkingSet._build_master()
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources/__init__.py", line 583, in _build_master
ws.require(__requires__)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources/__init__.py", line 900, in require
needed = self.resolve(parse_requirements(requirements))
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources/__init__.py", line 786, in resolve
raise DistributionNotFound(req, requirers)
pkg_resources.DistributionNotFound: The 'importlib-resources>=1.0' distribution was not found and is required by virtualenv
It seems doesn't work and I try the "sudo pip3 uninstall virtualenv" to uninstall it successfully, but it seems not really be removed:
% which virtualenv
/usr/local/bin/virtualenv
I have no idea about this, could you help me? I just want to run virtualenv normally and create flask project ...
PS. I can "sudo pip3 install flask" and "pip3 show flask" but still cannot run flask cammand (command not found), what should I do?
Thanks a lot!
try being explicit in the version of python you are using and install using -m pip instead
python3 -m pip install virtualenv
python3 -m virtualenv venv # create a new venv in ./venv
source ./venv/bin/activate # activate your new venv
often times the pip/pip3 just isnt pointing at the same python version you think you are using... by using this technique you are sure to be using the correct python and pip
I am trying to install Python 3.6 on Ubuntu 14.06. I have tried the get-apt command and I have tried to install from a tarball. Either way this is the error I receive.
:~/Downloads$ pip install Python-43.4.6.tar.gz
Requirement 'Python-43.4.6.tar.gz' looks like a filename, but the file does not exist
Processing ./Python-43.4.6.tar.gz
Exception: Traceback (most recent call last):
File "/usr/lib/python2.7/dist-packages/pip/basecommand.py", line 209, in main status = self.run(options, args)
File "/usr/lib/python2.7/dist-packages/pip/commands/install.py", line 328, in run wb.build(autobuilding=True)
File "/usr/lib/python2.7/dist-packages/pip/wheel.py", line 748, in build self.requirement_set.prepare_files(self.finder)
File "/usr/lib/python2.7/dist-packages/pip/req/req_set.py", line 360, in prepare_files ignore_dependencies=self.ignore_dependencies))
File "/usr/lib/python2.7/dist-packages/pip/req/req_set.py", line 577, in _prepare_file session=self.session, hashes=hashes)
File "/usr/lib/python2.7/dist-packages/pip/download.py", line 798, in unpack_url unpack_file_url(link, location, download_dir, hashes=hashes) File "/usr/lib/python2.7/dist-packages/pip/download.py", line 705, in unpack_file_url unpack_file(from_path, location, content_type, link) File "/usr/lib/python2.7/dist-packages/pip/utils/__init__.py", line 620, in unpack_file tarfile.is_tarfile(filename) or
File "/usr/lib/python2.7/tarfile.py", line 2622, in is_tarfile t = open(name)
File "/usr/lib/python2.7/tarfile.py", line 1673, in open return func(name, "r", fileobj, **kwargs)
File "/usr/lib/python2.7/tarfile.py", line 1738, in gzopen fileobj = gzip.GzipFile(name, mode, compresslevel, fileobj)
File "/usr/lib/python2.7/gzip.py", line 94, in __init__ fileobj = self.myfileobj = __builtin__.open(filename, mode or 'rb')
IOError: [Errno 2] No such file or directory: '/home/michael/Downloads/Python-43.4.6.tar.gz'
You are using pip version 8.1.1, however version 9.0.1 is available. You should consider upgrading via the 'pip install --upgrade pip' command.
:~/Downloads$ pip install --upgrade pip
Collecting pip
Downloading pip-9.0.1-py2.py3-none-any.whl (1.3MB) 100% |████████████████████████████████| 1.3MB 662kB/s Installing collected packages: pip
Successfully installed pip-8.1.1
You are using pip version 8.1.1, however version 9.0.1 is available. You should consider upgrading via the 'pip install --upgrade pip' command.
~/Downloads$ pip -V
pip 9.0.1 from /home/michael/.local/lib/python2.7/site-packages (python 2.7)
~/Downloads$ python -V
Python 2.7.12
~/Downloads$ python3 -V
Python 3.5.2
Did I download the wrong tarball or is there a way to insure that I am not install with for Python 2.7? Also, is the pip version error related?
TIA
First try using the upgrade command in pip and see if that fixes the version problem
pip3 install --upgrade pip
otherwise I would recommend uninstalling and performing a fresh install.
Use the following commands to setup python
sudo apt-get update
sudo apt-get -y upgrade
sudo apt-get install python3.6 python3-pip idle3
pip3 install numpy
pip3 install spyder
pip3 is the command for using python installer for python3.
to use idle3, just type in into the command window
idle3
I suggest to install spyder using pip3 as spyder is a more advanced idle which can track variables and code writing. makes it a bit easier in locating errors and such.
Many linux distribution provide tkinter, IDLE (which uses tkinter), and turtle (which also uses tkinter) as separate distribution. Searching SO for [tkinter] install tkinter on ubuntu displays previous questions with answers.
sudo apt-get install python3-tk
may be what you need but details may have change since previous answers.
I'm trying to install Pelican for python using pip install pelican, but I get these errors. I use Python 2.7.9 bundled with Mac OSX
Exception:
Traceback (most recent call last):
File "/Library/Python/2.7/site-packages/pip-7.1.2-py2.7.egg >/pip/basecommand.py", line 211, in main
status = self.run(options, args)
File "/Library/Python/2.7/site-packages/pip-7.1.2-py2.7.egg
/pip/commands /install.py", line 311, in run
root=options.root_path,
File "/Library/Python/2.7/site-packages/pip-7.1.2-py2.7.egg/pip/req
/req_set.py", line 646, in install
**kwargs
File "/Library/Python/2.7/site-packages/pip-7.1.2-py2.7.egg/pip/req
/req_install.py", line 803, in install
self.move_wheel_files(self.source_dir, root=root)
File "/Library/Python/2.7/site-packages/pip-7.1.2-py2.7.egg/pip/req
/req_install.py", line 998, in move_wheel_files
isolated=self.isolated,
File "/Library/Python/2.7/site-packages/pip-7.1.2-py2.7.egg/pip/wheel.py",
line 339, in move_wheel_files
clobber(source, lib_dir, True)
File "/Library/Python/2.7/site-packages/pip-7.1.2-py2.7.egg/pip/wheel.py", >line 310, in clobber
ensure_dir(destdir)
File "/Library/Python/2.7/site-packages/pip-7.1.2-py2.7.egg/pip/utils
/__init__.py", line 71, in ensure_dir
os.makedirs(path)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7
/os.py", line 157, in makedirs
mkdir(name, mode)
OSError: [Errno 13] Permission denied: '/Library/Python/2.7/site-packages/pelican'
Evens-MacBook-Pro:~ even$
Your normal user cannot install to the system-wide Python package directory. Instead of using sudo, install the package locally for your user account:
pip install --user pelican
That error occured because you don't have permission to write on that system directory. Hence the OSError: [Errno 13] Permission denied.
If you want to install it system wide, you have to run pip with superuser rights in order to gain permission:
sudo pip install pelican
Although, that wouldn't be necessary -- nor a good practice --, for instance, if you are installing inside a virtualenv.
Another possibility, as referred in this answer pointed out by #pherris, is to append the --user flag to the pip command. This would install the package only to the current user:
pip install pelican --user
Modifying the system-level installation of Python (or Ruby, or Perl...) can turn into a mess, and I have had my work there trashed in the past by system updates. Apple doesn't really guarantee your local changes will be preserved after an OS update.
You are likely better off installing your own versions using something like Homebrew, which installs into /usr/local.
Homebrew has Python 2.x and 3.x available (and they can co-exist very well). It keeps up with new releases better than Apple does. Homebrew also has many other Unix things that you may or may not find useful.
After installing Homebrew, installing Python is simple:
brew install python
brew install python3
Make sure /usr/local/bin is early in your $PATH. It also provides you with pip and pip3 to install Python package for both 2.x and 3.x.
Whenever I install my python project using 'python setup.py install', and invoke my project on a CentOS vagrant box, it works great. The dependencies get resolved perfectly.
However, if I create an rpm using fpm for my project, install the rpm using 'rpm -i rpm-file.rpm', manually install the dependencies using 'pip install -r requirements-file-path.txt' and then invoke my project on another CentOS vagrant box, I get the following error:
File "/usr/bin/<name-of-my-project>", line 5, in <module>
from pkg_resources import load_entry_point
File "/usr/lib/python2.6/site-packages/pkg_resources.py", line 2655, in <module>
working_set.require(__requires__)
File "/usr/lib/python2.6/site-packages/pkg_resources.py", line 648, in require
needed = self.resolve(parse_requirements(requirements))
File "/usr/lib/python2.6/site-packages/pkg_resources.py", line 546, in resolve
raise DistributionNotFound(req)
pkg_resources.DistributionNotFound: fabric==1.10.2
Uninstalling the dependencies using 'pip uninstall' and reinstalling them doesn't fix the problem. What am I missing?
Just found the answer on the Fabric FAQ page: http://www.fabfile.org/faq.html/. Executing:
sudo pip install -U setuptools
Then re-installing the dependencies and project solved my problem. But welcome to other answers.
I'm trying to create a Flask application to push to Heroku. When I try to create a virtualenv in the folder, I'm thrown this error:
photo-crawl › sudo virtualenv venv --distribute
Password:
New python executable in venv/bin/python
Installing distribute............................................................................................................................................................................................................................done.
Installing pip....
Complete output from command /Users/evansiegel/In...rawl/venv/bin/python -x /Users/evansiegel/In...env/bin/easy_install /Library/Python/2.7/...ort/pip-1.2.1.tar.gz:
/Users/evansiegel/Involvio/photo-crawl/venv/bin/python: can't open file '/Users/evansiegel/Involvio/photo-crawl/venv/bin/easy_install': [Errno 2] No such file or directory
----------------------------------------
...Installing pip...done.
Traceback (most recent call last):
File "/usr/local/bin/virtualenv", line 9, in <module>
load_entry_point('virtualenv==1.8.4', 'console_scripts', 'virtualenv')()
File "/Library/Python/2.7/site-packages/virtualenv.py", line 964, in main
never_download=options.never_download)
File "/Library/Python/2.7/site-packages/virtualenv.py", line 1076, in create_environment
install_pip(py_executable, search_dirs=search_dirs, never_download=never_download)
File "/Library/Python/2.7/site-packages/virtualenv.py", line 667, in install_pip
filter_stdout=_filter_setup)
File "/Library/Python/2.7/site-packages/virtualenv.py", line 1042, in call_subprocess
% (cmd_desc, proc.returncode))
OSError: Command /Users/evansiegel/In...rawl/venv/bin/python -x /Users/evansiegel/In...env/bin/easy_install /Library/Python/2.7/...ort/pip-1.2.1.tar.gz failed with error code 2
It seems that for some reason virtualenv is not putting everything it should be putting into the venv/bin folder. Right now, only python and two aliases, python2 and python2.7 are in there.
Thanks!
I believe this is caused by a bug in older versions of virtualenv and/or pip. It looks like you're using virtualenv 1.8.4 and pip 1.2.1. Is it possible for you to upgrade to latest virtualenv and pip (currently virtualenv 1.9.1 and pip 1.3.1)?
This should do it, if you have install privileges:
pip install pip --upgrade
pip install virtualenv --upgrade
At that point running the same command (i.e. sudo virtualenv venv --distribute) should give you what you want.