I have a Python 2 package that I'm trying to upgrade to Python 3. It was written by someone who used to work on the same team I'm on now but who is no longer with the company, and unfortunately nobody left on the team is able to help out.
After running 2to3 on the files of the package, I ran python setup.py sdist to create a package, placed the package in a local repository, then attempted to use pip install to install the package. It ended up erroring out with the following:
Exception:
Traceback (most recent call last):
File "/home/user/project/lib/python3.5/site-packages/pip/basecommand.py", line 223, in main
status = self.run(options, args)
File "/home/user/project/lib/python3.5/site-packages/pip/commands/install.py", line 297, in run
root=options.root_path,
File "/home/user/project/lib/python3.5/site-packages/pip/req/req_set.py", line 622, in install
**kwargs
File "/home/user/project/lib/python3.5/site-packages/pip/req/req_install.py", line 808, in install
self.move_wheel_files(self.source_dir, root=root)
File "/home/user/project/lib/python3.5/site-packages/pip/req/req_install.py", line 1003, in move_wheel_files
isolated=self.isolated,
File "/home/user/project/lib/python3.5/site-packages/pip/wheel.py", line 340, in move_wheel_files
assert info_dir, "%s .dist-info directory not found" % req
AssertionError: my-package-name .dist-info directory not found
The old Python 2 version of the package didn't have anything called .dist-info in the .tgz archive, and it installed just fine. Does anyone know what's going on here and how to fix it?
In my case this was resolved by deleting AppData\Local\pip\Cache folder (windows). Should be fairly similar for other operating systems.
Related
I installed Python 3.9 using winget.
PS C:\Users\andre> winget list PythonSoftware
Name ID Version
-----------------------------------------------------------------------
Python 3.9 PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0 3.9.2544.0
I am trying to install poetry. Therefore, I downloaded the new installation script from https://install.python-poetry.org/ and run it within a Windows terminal. Here's the output:
PS C:\Users\andre\Downloads> python .\install-poetry.py
Retrieving Poetry metadata
# Welcome to Poetry!
This will download and install the latest version of Poetry,
a dependency and package manager for Python.
It will add the `poetry` command to Poetry's bin directory, located at:
C:\Users\andre\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Scripts
You can uninstall at any time by executing this script with the --uninstall option,
and these changes will be reverted.
Installing Poetry (1.1.12)
Installing Poetry (1.1.12): Creating environment
Actual environment location may have moved due to redirects, links or junctions.
Requested location: "C:\Users\andre\AppData\Roaming\pypoetry\venv\Scripts\python.exe"
Actual location: "C:\Users\andre\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\Roaming\pypoetry\venv\Scripts\python.exe"
Actual environment location may have moved due to redirects, links or junctions.
Requested location: "C:\Users\andre\AppData\Roaming\pypoetry\venv\Scripts\python.exe"
Actual location: "C:\Users\andre\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\Roaming\pypoetry\venv\Scripts\python.exe"
Installing Poetry (1.1.12): An error occurred. Removing partial environment.
Poetry installation failed.
See C:\Users\andre\Downloads\poetry-installer-error-bzs5mfpr.log for error logs.
And finally the output of the respective log file:
No pyvenv.cfg file
Traceback:
File "C:\Users\andre\Downloads\install-poetry.py", line 872, in main
return installer.run()
File "C:\Users\andre\Downloads\install-poetry.py", line 503, in run
self.install(version)
File "C:\Users\andre\Downloads\install-poetry.py", line 524, in install
with self.make_env(version) as env:
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.2544.0_x64__qbz5n2kfra8p0\lib\contextlib.py", line 119, in __enter__
return next(self.gen)
File "C:\Users\andre\Downloads\install-poetry.py", line 596, in make_env
raise e
File "C:\Users\andre\Downloads\install-poetry.py", line 582, in make_env
yield VirtualEnvironment.make(env_path)
File "C:\Users\andre\Downloads\install-poetry.py", line 317, in make
env.pip("install", "--disable-pip-version-check", "--upgrade", "pip")
File "C:\Users\andre\Downloads\install-poetry.py", line 340, in pip
return self.python("-m", "pip", "--isolated", *args, **kwargs)
File "C:\Users\andre\Downloads\install-poetry.py", line 337, in python
return self.run(self._python, *args, **kwargs)
File "C:\Users\andre\Downloads\install-poetry.py", line 330, in run
raise PoetryInstallationError(
Apparently, there's some issue with the place where Python has been installed, isn't it? How can I solve that issue?
This indeed is path issue with multiple versions of Python Installation , especially the version from Microsoft is not setting the path properly us the installer from https://www.python.org/downloads/ it fixes the error
I have git pulled a python package (I think that is the correct terminology) that I already had installed and working.
So now it is up to date, apparently I needed to update it using pip. I did the following:
pip install the_package --upgrade
But I got the following error message:
Exception:
Traceback (most recent call last):
File "/opt/work/python/2.7.13/lib/python2.7/site-packages/pip/basecommand.py", line 215, in main
status = self.run(options, args)
File "/opt/work/python/2.7.13/lib/python2.7/site-packages/pip/commands/install.py", line 335, in run
wb.build(autobuilding=True)
File "/opt/work/python/2.7.13/lib/python2.7/site-packages/pip/wheel.py", line 749, in build
self.requirement_set.prepare_files(self.finder)
File "/opt/work/python/2.7.13/lib/python2.7/site-packages/pip/req/req_set.py", line 380, in prepare_files
ignore_dependencies=self.ignore_dependencies))
File "/opt/work/python/2.7.13/lib/python2.7/site-packages/pip/req/req_set.py", line 666, in _prepare_file
check_dist_requires_python(dist)
File "/opt/work/python/2.7.13/lib/python2.7/site-packages/pip/utils/packaging.py", line 48, in check_dist_requires_python
feed_parser.feed(metadata)
File "/opt/work/python/2.7.13/lib/python2.7/email/feedparser.py", line 177, in feed
self._input.push(data)
File "/opt/work/python/2.7.13/lib/python2.7/email/feedparser.py", line 99, in push
parts = data.splitlines(True)
AttributeError: 'NoneType' object has no attribute 'splitlines'
I'm not sure what the problem is. Could someone please point me in the right direction?
I can't say much about the error you're seeing, but my best guess is that the version of the package from git is interfering with the pip installed one. Perhaps something went wrong when trying to upgrade starting with the gitHub version (or wherever it came from) and not with an officially published one.
If a package is available through PyPI you shouldn't need to do anything besides pip install <somepackage>. I would recommend removing all files downloaded via git and those modules in your python lib so you can start over completely. From there just use pip install <packagename>.
If you're not already in a python virtual environment I would recommend creating one too, so that these things are easier to fix.
Edit: I just found elsewhere on this site that you can use pip show <packagename> to show the install location of the package if you're not in a venv (or if you are).
I am trying to use pip, and every time I run a command to install or upgrade, I see this type of error (OSError).
I don't like having to sudo just to install packages, is this required?
Exception:
Traceback (most recent call last):
File "/Library/Python/2.7/site-packages/pip/basecommand.py", line 215, in main
status = self.run(options, args)
File "/Library/Python/2.7/site-packages/pip/commands/install.py", line 342, in run
prefix=options.prefix_path,
File "/Library/Python/2.7/site-packages/pip/req/req_set.py", line 784, in install
**kwargs
File "/Library/Python/2.7/site-packages/pip/req/req_install.py", line 851, in install
self.move_wheel_files(self.source_dir, root=root, prefix=prefix)
File "/Library/Python/2.7/site-packages/pip/req/req_install.py", line 1064, in move_wheel_files
isolated=self.isolated,
File "/Library/Python/2.7/site-packages/pip/wheel.py", line 345, in move_wheel_files
clobber(source, lib_dir, True)
File "/Library/Python/2.7/site-packages/pip/wheel.py", line 316, in clobber
ensure_dir(destdir)
File "/Library/Python/2.7/site-packages/pip/utils/__init__.py", line 83, 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/docutils'
You're trying to modify a location shared amongst all users. You can't do that without sudo-ing, for good reason (otherwise, people could replace, say, python, with a program that deletes all your user data, or copies it to their home folder for perusal, etc.).
If you want to only make the changes for yourself, not others, you can pass pip the --user argument to install to ~/.local such that the new package is installed only for you, not other users.
Virtual environments are another option, but that's overkill to an extent (an active virtual environment isolates you completely from even the system site-packages directory, so you must individually install all packages again if they're needed).
Linux and Mac OS come with their own packaged python interpreter, and it is not advisable to use them for your development purpose. Start using virtualenv, a tool to create isolated Python environments in which you can install any packages, test installation of your own libraries and much more without affecting the systemwide installed python environment. Check out their site for tutorials on how to install, create and run scripts in a virtualenv.
Trying to use virutalenv version 1.6.4 (the latest at writing this post) on 10.7, Lion with yes Xcode 4 installed from mac app store, yet i'm getting the below error message:
New python executable in SUPENV/bin/python
Error [Errno 2] No such file or directory while executing command install_name_tool -change /System/Library/Fram.../Versions/2.7/Python #executable_path/../.Python SUPENV/bin/python
Could not call install_name_tool -- you must have Apple's development tools installed
Traceback (most recent call last):
File "/usr/local/bin/virtualenv", line 8, in <module>
load_entry_point('virtualenv==1.6.4', 'console_scripts', 'virtualenv')()
File "/Library/Python/2.7/site-packages/virtualenv-1.6.4-py2.7.egg/virtualenv.py", line 810, in main
never_download=options.never_download)
File "/Library/Python/2.7/site-packages/virtualenv-1.6.4-py2.7.egg/virtualenv.py", line 901, in create_environment
site_packages=site_packages, clear=clear))
File "/Library/Python/2.7/site-packages/virtualenv-1.6.4-py2.7.egg/virtualenv.py", line 1166, in install_python
py_executable])
File "/Library/Python/2.7/site-packages/virtualenv-1.6.4-py2.7.egg/virtualenv.py", line 843, in call_subprocess
cwd=cwd, env=env)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 672, in __init__
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 1202, in _execute_child
OSError: [Errno 2] No such file or directory
Any hints on how to solve this problem... I guess the first would be to check if install_name_tool is present on my system, and then force virtualenv to use it...
thanks in advance!
You need to both install XCode, run it, and select the optional "command line tools" package and then install those. In more detail:
Download XCode from the App Store
Run the downloaded XCode binary from Applications or Launchpad
Select XCode->Preferences, then choose the "Downloads" tab
Click on the "Command Line Tools" selection and install those
Did you actually install Xcode 4? Downloading it from the App Store only downloads the installer for it. Then you need to run the installer; you should find the installer downloaded to /Applications. After you run it, you should find install_name_tool here:
$ which install_name_tool
/usr/bin/install_name_tool
With newer versions of virtualenv (at least from 1.8.4 on) it is no longer necessary to install the "Command Line Tools" package from Xcode.
I am trying to list ScientificPython as a dependency in my setup.py. However, during the installation process, python seems to not find the package. What is wrong in my approach?
Here is my setup:
import setuptools
setuptools.setup(name = 'MyPack', version = '0.1',
description= 'Description.',
author = 'Me',
packages = setuptools.find_packages(),
install_requires = ['ScientificPython'],
dependency_links = ["https://sourcesup.cru.fr/frs/?group_id=180&release_id=1351#stable-releases-2-8-title-content"])
And this is the important part of the output when I run python setup.py install:
Processing dependencies for MyPack==0.1
Searching for ScientificPython
Reading https://sourcesup.cru.fr/frs/?group_id=180&release_id=1351#stable-releases-2-8-title-content
Download error: unknown url type: https -- Some packages may not be found!
Reading http://pypi.python.org/simple/ScientificPython/
Reading http://dirac.cnrs-orleans.fr/ScientificPython/
Reading http://starship.python.net/~hinsen/ScientificPython/
No local packages or download links found for ScientificPython
Best match: None
Traceback (most recent call last):
File "setup.py", line 22, in <module>
dependency_links = ["https://sourcesup.cru.fr/frs/?group_id=180&release_id=1351#stable-releases-2-8-title-content"])
File "/home/woltan/local/lib/python2.7/distutils/core.py", line 152, in setup
dist.run_commands()
File "/home/woltan/local/lib/python2.7/distutils/dist.py", line 953, in run_commands
self.run_command(cmd)
File "/home/woltan/local/lib/python2.7/distutils/dist.py", line 972, in run_command
cmd_obj.run()
File "/home/woltan/local/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg/setuptools/command/install.py", line 76, in run
File "/home/woltan/local/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg/setuptools/command/install.py", line 104, in do_egg_install
File "/home/woltan/local/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg/setuptools/command/easy_install.py", line 211, in run
File "/home/woltan/local/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg/setuptools/command/easy_install.py", line 427, in easy_install
File "/home/woltan/local/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg/setuptools/command/easy_install.py", line 478, in install_item
File "/home/woltan/local/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg/setuptools/command/easy_install.py", line 519, in process_distribution
File "/home/woltan/local/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg/pkg_resources.py", line 563, in resolve
File "/home/woltan/local/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg/pkg_resources.py", line 799, in best_match
File "/home/woltan/local/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg/pkg_resources.py", line 811, in obtain
File "/home/woltan/local/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg/setuptools/command/easy_install.py", line 434, in easy_install
File "/home/woltan/local/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg/setuptools/package_index.py", line 475, in fetch_distribution
AttributeError: 'NoneType' object has no attribute 'clone'
Maybe one issue is, that ScientificPython is somehow not accessible though PyPI, or at least not downloadable as easy_install ScentificPython will fail with No local packages or download links found for ScentificPython.
What do I need to do in order to install ScientificPython with setuptools?
Have you tried putting the direct download link (https://sourcesup.cru.fr/frs/download.php/2309/ScientificPython-2.8.tar.gz) into the dependency_links rather than the html page as your script seems not to find the package and then tries to install None.
edit: just noticed: python apparently is not able to open https resources - try uploading it somewhere without https, using normal http
edit 2: Why don't you just put the whole ScientificPython folder into your distribution folder and make sure its setup.py (or whatever else you need to call) is called by your setup.py?
The problem is specifically that its trying to make an http connection to a https site. From what I can tell setuptools does not support connections to https. You're going to have to use another method for getting those packages.
My recommendation, if you want to use setuptools, is that you detail in the README for the file that they have to download that dependency and install it and then have the dependency in the setuptools that fails to the install if they don't have it.
Python is unable to handle https protocol, install openssl-devel package and reinstall the python to fix this.
I was getting similar error when installing MyProxyClient using easy_install:
"Download error: unknown url type: https -- Some packages may not be found!"
and other errors about not finding openssl headers.
So installing libssl-dev (on Ubuntu) solved the problem for me!