1

I am trying to use Perforce with python. When I did the line:

import P4

The error message I got was:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Python27\lib\site-packages\P4.py", line 410, in <module>
    import P4API
ImportError: No module named P4API

Tried looking at different answers none of them solved my problem... Seems like P4 has a very messy code management and names of modules kept changing... Someone pls enlighten me with what happens with the python api for p4 and how to install them?

BTW I use Windows 10 64-bit, Thanks!

Dino
  • 23
  • 1
  • 3
  • Have you installed all the required packages? Where did you get it? Looking at download links on the Perforce site puzzled me, and apparently several components are required. – 9000 May 31 '17 at 15:19
  • 2
    Problem solved by running 'pip install --upgrade p4python' – Dino May 31 '17 at 16:00

2 Answers2

1

I faced the same issue when I was using Python3.8 with Eclipse (Eclipse IDE for Java Developers Version: 2019-09 R (4.13.0)).

Also, I was using p4python p4python-2019.1.1858212.tar.gz (92.5 kB) and manually copied in python3.8 installed location.

pip install p4python did not work in MS-DOS due to some ssl error.

Cause: Python3.8 is the culprit since above p4python was not compatible with it.

Solution:

  1. Use Python3.7
  2. Trigger pip install p4python from MSDOS like below: C:\Program Files (x86)\Python\Python37\Scripts>pip install p4python

  3. p4python gets downloaded and installed successfully in Python3.7. No need to manually download from https://pypi.org/project/p4python/#files

  4. Now use P4.connect() like below, it works fine.

    from P4 import P4

    p4 = P4() p4.port = "xxxx" p4.user = "vivek.goynar" p4.client = ""

    p4.connect()

vivekgoynar
  • 31
  • 1
  • 3
0

I think it should be only P4, not P4API

from P4 import P4

I don't see any P4API module in P4 package

richard
  • 46
  • 6