Python Forum
ImportError: cannot import name 'Main' => Cannot install module with pip
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
ImportError: cannot import name 'Main' => Cannot install module with pip
#1
Hello,

I am trying to compile a python script and I have to install a module called "main". when I try to install it with pip I am getting the following erorr :


Quote:ImportError: cannot import name 'Main'
PS C:\pdfconvert_source> pip install main
Collecting main
Using cached main-0.1.tar.gz
Installing collected packages: main
Running setup.py install for main ... error
Complete output from command c:\users\mederic\appdata\local\programs\python\python36-32\python.exe -u -c "import setuptools, tokenize;__file__='C:\\Users\\Mederic\\AppData\\Local\\Temp\\pip-build-1096gtzi\\main\\setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record C:\Users\Mederic\AppData\Local\Temp\pip-xfhli32r-record\install-record.txt --single-version-externally-managed --compile:
running install
running build
running build_scripts
creating build
creating build\scripts-3.6
error: file 'C:\Users\Mederic\AppData\Local\Temp\pip-build-1096gtzi\main\main' does not exist

----------------------------------------
Command "c:\users\admin\appdata\local\programs\python\python36-32\python.exe -u -c "import setuptools, tokenize;__file__='C:\\Users\\Admin\\AppData\\Local\\Temp\\pip-build-1096gtzi\\main\\setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record C:\Users\Admin\AppData\Local\Temp\pip-xfhli32r-record\install-record.txt --single-version-externally-managed --compile" failed with error code 1 in C:\Users\Admin\AppData\Local\Temp\pip-build-1096gtzi\main\
PS C:\pdfconvert_source>

How can I fix this ?

Thank you in advance for your help
Reply
#2
If you write pip install main, it means that you are trying to install this module from pypi, which calculates the price of a book from its title. Is it really what you want to do?

If python writes ImportError: cannot import name 'Main', it means that it cannot import a class or function or some other python object named Main. The solution is not to use pip. If you post the whole error traceback here, it will probably help us diagnose the error.
Reply
#3
Thank you. I am new to Python and didn't know that. I assumed it was a module.

This is what I am getting in the powershell (I am on Windows 10) :

Quote:PS C:\Users\admin> cd C:\pdfconvert_source
PS C:\pdfconvert_source> python starter.py
Traceback (most recent call last):
File "starter.py", line 4, in <module>
from pdfconvert_qt import Main
File "C:\pdfconvert_source\pdfconvert_qt.py", line 14, in <module>
import starter
File "C:\pdfconvert_source\starter.py", line 4, in <module>
from pdfconvert_qt import Main
ImportError: cannot import name 'Main'
PS C:\pdfconvert_source>
Reply
#4
Do you have a link to what you are trying to install?
Reply
#5
No it's a program that was made by a friend of mine... does the error I am getting means there is something wrong with the script?
Reply
#6
The error means that python detects a cyclic import: the starter.py file needs to import an object named Main from the file pdfconvert_qt.py, and this file in turn needs to import the starter module. This is a design flaw in the program. There may be solutions, but without the code it is difficult to help.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  is import cointegration_analysis a recognized module mitcht33 1 384 Nov-06-2023, 09:29 PM
Last Post: deanhystad
  Resolving ImportError: No module named gdb (Python in C++) mandaxyz 3 1,309 Oct-04-2023, 02:43 PM
Last Post: mandaxyz
  problem in import module from other folder akbarza 5 1,258 Sep-01-2023, 07:48 AM
Last Post: Gribouillis
  can not import anaconda pandas module. PySpark pandas module is imported!! aupres 0 680 Aug-06-2023, 01:09 AM
Last Post: aupres
Question Cannot import easysnmp: ImportError: libnetsnmp.so.30 Calab 4 999 Jun-08-2023, 08:52 PM
Last Post: Gribouillis
  import module error tantony 5 3,358 Dec-15-2022, 01:55 PM
Last Post: Lauraburmrs
  Import a module one step back of the path prathampatel9 1 1,036 Sep-21-2022, 01:34 PM
Last Post: snippsat
  No module found when I run a main.py tomtom 2 1,411 Jul-20-2022, 09:24 AM
Last Post: tomtom
  ImportError: No module named PIL rudeoil18 9 6,586 Mar-03-2022, 01:25 PM
Last Post: snippsat
  Install any library via pip get an error cannot import name 'SCHEME_KEYS' from 'pip. Anldra12 2 10,487 Jan-04-2022, 01:05 PM
Last Post: Anldra12

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020