15

I'm working on a project which was written in Python 2, and I'm upgrading it to Python 3. So far, I've just been finding minor syntax errors which are easily fixable. What I've done is created a new project in Python 3, ensured that it worked, and copies chunks of code from the old project into the new one.

Right now, I'm having trouble with pysvn. Initially, I was getting this error:

ImportError: No module named 'pysvn'

At this point, I tried using pip install pysvn, which didn't work. I got the following:

pip install pysvn

Collecting pysvn

Could not find a version that satisfies the requirement pysvn (from versions:)

No matching distribution found for pysvn

So then after a bit of research, I went to the pysvn download site and tried:

>pip install --index-url http://pysvn.tigris.org/project_downloads.html pysvn, which gave me this error:

Collecting pysvn

The repository located at pysvn.tigris.org is not a trusted or secure host and is being ignored. If this repository is available via HTTPS it is recommended to use HTTPS instead, otherwise you may silence this warning and allow it anyways with '--trusted-host pysvn.tigris.org'.

and also the same error as when I tried >pip install pysvn.

My next step was to manually download the .exe file for the version I needed, and I was able to successfully install pysvn. I have checked the site-packages directory, and pysvn is indeed there, but pip still can't tell me anything about it:

>pip show pysvn

>

When I do this for another installed module, selenium for example, I get the following:

pip show selenium


Metadata-Version: 1.1

Name: selenium

Version: 2.49.2

Summary: Python bindings for Selenium

Home-page: https://github.com/SeleniumHQ/selenium/

Author: UNKNOWN

Author-email: UNKNOWN

License: UNKNOWN

Location: ...\lib\site-packages

Requires:

I was able to verify that the installation of pysvn was successful because my project now runs instead of giving me that ImportError.

So why can pip not give me information for another module in the same directory that was successfully installed?

Community
  • 1
  • 1
DJGrandpaJ
  • 571
  • 3
  • 7
  • 20
  • First step is making sure that pysvn is located where you think by doing something like this: `>>> import pysv >>> import inspect >>> inspect.getfile(pysvn)` – Igor Feb 24 '16 at 18:52
  • According to what that gave me, it's exactly where I found it after it installed (at `lib\site-packages\pysvn`). – DJGrandpaJ Feb 24 '16 at 19:38
  • Try running `python -m pip list`. Does it appear in the list of installed packages? – Igor Feb 24 '16 at 21:16
  • 1
    @Igor No. My guess is that pip didn't install it and is unaware of where it came from, but the [documentation for pip list](http://pip-python3.readthedocs.org/en/latest/reference/pip_list.html) doesn't specify whether this is the case. However, my code is running perfectly regardless; I'm really just curious at this point. – DJGrandpaJ Feb 24 '16 at 21:38
  • 1
    I guess it would make sense that since you installed the module outside of pip package manager, pip wouldn't know about it. But I would also like to learn the answer for sure. Please post if you come across it. – Igor Feb 24 '16 at 21:39

2 Answers2

6

As it turns out, because I didn't use pip install for pysvn, pip didn't know that pysvn existed. Because it wasn't available from PyPI (the Python Package Index), there was no way that pip could see it (because that's where pip goes first to find packages that it's attempting to install).

From the pip user guide:

pip supports installing from PyPI, version control, local projects, and directly from distribution files.

Since I had eventually downloaded pysvn from its own download site (which was not any of the above 4 options) and ran the .exe manually, pip simply doesn't know about it even though it's in the same directory as other packages installed by pip.

I suppose I could've also retrieved the distribution files and used pip with those, but my workaround did the trick.

DJGrandpaJ
  • 571
  • 3
  • 7
  • 20
  • 3
    PyPI does not allow for more then 1 binary for a version of python. Pysvn supports one binary for each SVN version. Which all means PyPI is not powerful enough to support extensions like pysvn. Its a known issue with PyPI. – Barry Scott Aug 16 '16 at 11:28
  • 1
    On linux systems you typically can just install the Debian/Fedora package. The Mac and Windows situation is far more complex. Its not easy to just build pysvn. You have to build SVN and its dependencies. Again this far beyond what PyPi can helpo with. – Barry Scott Aug 16 '16 at 11:33
  • In its download page, pysvn speaks of "Linux binary kits" and gives a very simple procedure for Debian-like distr: `apt-get install python-svn svn-workbench` ... is it outdated? – Sandburg Jan 24 '19 at 10:06
2

My way on linux:

Get sources from here

tar -zxf pysvn-1.9.10.tar.gz
apt-get install subversion libsvn1 libsvn-dev make g++
cd pysvn-1.9.10/Source
python setup.py configure --pycxx-dir=/pysvn-1.9.10/Import/pycxx-7.1.3/
make

Here i've got errors below:

Compile: /pysvn-1.9.10/Import/pycxx-7.1.3/Src/cxxsupport.cxx into cxxsupport.o
/pysvn-1.9.10/Import/pycxx-7.1.3/Src/cxxsupport.cxx:42:10: fatal error: Src/Python3/cxxsupport.cxx: No such file or directory
#include "Src/Python3/cxxsupport.cxx"

Compile: /pysvn-1.9.10/Import/pycxx-7.1.3/Src/cxxextensions.c into cxxextensions.o
/pysvn-1.9.10/Import/pycxx-7.1.3/Src/cxxextensions.c:42:10: fatal error: Src/Python3/cxxextensions.c: No such file or directory
#include "Src/Python3/cxxextensions.c"

It is needed to edit that files: vi /pysvn-1.9.10/Import/pycxx-7.1.3/Src/cxxsupport.cxx

change #include "Src/Python3/cxxsupport.cxx" to
#include "Python3/cxxsupport.cxx"

and same on second file. Than make again:

make clean && make
...
Compile: /code/pysvn-1.9.10/Import/pycxx-7.1.3/Src/cxxextensions.c into cxxextensions.o
Compile: /code/pysvn-1.9.10/Import/pycxx-7.1.3/Src/IndirectPythonInterface.cxx into IndirectPythonInterface.o
Compile: /code/pysvn-1.9.10/Import/pycxx-7.1.3/Src/cxx_exceptions.cxx into cxx_exceptions.o
Link pysvn/_pysvn_3_7.so

Then just copy it to the site-packages (change to yours directory):

mkdir /usr/local/lib/python3.7/site-packages/pysvn
cp /code/pysvn-1.9.10/Sources/pysvn/__init__.py /usr/local/lib/python3.7/site-packages/
cp /code/pysvn-1.9.10/Sources/pysvn/_pysvn*.so /usr/local/lib/python3.7/site-packages/
gek
  • 524
  • 6
  • 18