Pip does not find installation file

I get an error when trying to install a python package using pip.

It searches in a specific directory for "setup.py" after deploying the package and cannot find it there. The setup.py file is actually in the same directory.

He looks at:

'virtualenvs/pyling/build/nltk/setup.py' 

but actually he:

 virtualenvs/pyling $ ls build/nltk/nltk-2.0b9/ INSTALL.txt javasrc LICENSE.txt nltk PKG-INFO README.txt setup.py 

Is there a way to make pip available for this subfolder structure in a package?

thanks

+4
source share
5 answers

I added a small function and I will name it in the property definition for setup_py in the pip / req.py file.

it seems to work as I expect, that is, if the setup.py file is only one level deeper. we hope nothing breaks when tying and freezing ...

 import os def get_setup_path(in_path): print "starting path is %s"%in_path fileList=os.listdir(in_path) if fileList.__contains__("setup.py"): print "setup.py is indeed there" return in_path for f in fileList: f=os.path.join(in_path,f) if os.path.isdir(f): contents=os.listdir(f) if contents.__contains__("setup.py"): out_path=os.path.join(in_path,f) return out_path print "could not find setup.py by looking one level deeper" return in_path 

and then call it here in req.py

 (around line 195 in req.py) @property def setup_py(self): self.source_dir= get_setup_path(self.source_dir) return os.path.join(self.source_dir, 'setup.py') 
0
source

I found that pip runs a python script command line that looks like this:

 __file__ = '<path to package>/setup.py' from setuptools.command import egg_info def replacement_run(self): self.mkpath(self.egg_info) installer = self.distribution.fetch_build_egg for ep in egg_info.iter_entry_points('egg_info.writers'): # require=False is the change we're making: writer = ep.load(require=False) if writer: writer(self, ep.name, egg_info.os.path.join(self.egg_info,ep.name)) self.find_sources() egg_info.egg_info.run = replacement_run execfile(__file__) 

In the top-level directory of the package where setup.py was not there, I placed setup.py, which reproduced this behavior, but chdir'd in the directory containing the β€œreal” setup.py and executed, which is on end.

The only problem was that pip creates the "pip-egg-info" directory, which is expected to be populated, requiring the creation of a symbolic link in the directory with the "real" setup.py.

The new, top-level setup.py looks like this:

 #! /usr/bin/env python from os import chdir, symlink, getcwd from os.path import join, basename, exists filename = basename(__file__) chdir("python") setupdir = getcwd() egginfo = "pip-egg-info" if not exists(egginfo) and exists(join("..", egginfo)): symlink(join("..", egginfo), egginfo) __file__ = join(setupdir, filename) from setuptools.command import egg_info def replacement_run(self): self.mkpath(self.egg_info) installer = self.distribution.fetch_build_egg for ep in egg_info.iter_entry_points('egg_info.writers'): # require=False is the change we're making: writer = ep.load(require=False) if writer: writer(self, ep.name, egg_info.os.path.join(self.egg_info,ep.name)) self.find_sources() egg_info.egg_info.run = replacement_run execfile(__file__) 

It is probably fragile, but should continue to work until pip changes the command-line pin code that it generates

+1
source
  • fix the package so that it matches the standard package formats, i.e. setup.py should be in the top directory.

or

  • unzip the archive and pip point to the directory with the setup.py .
0
source

I already had this problem when calling pip from a directory other than the one in which setup.py is located. The solution added the following to setup.py:

import os os.chdir (os.path.dirname (os.path.abspath ( __file__ )))

Maybe you are calling pip from virtualenvs / pyling / build / nltk / where should it be virtualenvs / pyling / build / nltk / nltk-2.0b9 /? Then just add what I did.

0
source

I had a similar problem and refused to use the default url for pip. However, if you just want to install nltk, this works for me:

 pip install -E <virtualenv-dir> PyYAML #if you have not done so pip install -E <virtualenv-dir> --no-index --find-links=http://nltk.googlecode.com/ nltk 
0
source

Source: https://habr.com/ru/post/1343844/


All Articles