question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ImportError: cannot import name __version__

See original GitHub issue

Tried to install this packaged via

pip3 install pipreqs

which succeeded without error. However, I am unable to run it from the command line or import the library via the Python interpreter. In both cases I get the traceback below:

Python 3.5.3 (default, Jan 19 2017, 14:11:04) 
[GCC 6.3.0 20170118] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import pipreqs
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/users/me/.local/lib/python3.5/site-packages/pipreqs/pipreqs.py", line 37, in <module>
    from pipreqs import __version__
ImportError: cannot import name '__version__'

Environment info

  • Python 3.5.3

Output of uname -a

Linux ace-ws-15 4.9.0-6-amd64 #1 SMP Debian 4.9.88-1+deb9u1 (2018-05-07) x86_64 GNU/Linux

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:7

github_iconTop GitHub Comments

20reactions
ldahercommented, Dec 2, 2021

Although the question is a little bit old, I still consider relevant since I’ve faced the exactly same problem and the solution I found was to downgrade the “pipreqs” module to 0.4.8.

Btw… my scenario is different than presented here… The python version is 2.7.18 and according to the “History” session within “pipreqs” website (https://pypi.org/project/pipreqs) I’ve decided to teste version 0.4.8 based on the release date.

0reactions
DJJBanxcommented, Jun 10, 2021

I ran into the same issue because I was running the pipreqs.py file from site-packages to avoid adding it to path on windows. I called the file directly and it could not find version.

A fix for this is to edit the init.py file in the site-packages and copy all of the code defining author, email, and version

__author__ = 'Vadim Kravcenko'
__email__ = 'vadim.kravcenko@gmail.com'
__version__ = '0.4.10'

and paste it into the pipreqs.py file in place of

from pipreqs import __version__

On line 50. (Removing that import statement and defining the version in the file itself)

Read more comments on GitHub >

github_iconTop Results From Across the Web

Python ImportError: cannot import name __version__ ...
ImportError : cannot import name __version__​​ Try to modify the init.py in the root of the openpyxl paceage folder, don't read the version...
Read more >
How to Fix ImportError: Cannot Import Name in Python - Rollbar
The imported class is in a circular dependency. · The imported class is unavailable or was not created. · The imported class name...
Read more >
ImportError: cannot import name version · Issue #596 - GitHub
I try to install a module named "seq2seq" which use smart_open but when I try to run it I have this errror message...
Read more >
How to Fix : “ImportError: Cannot import name X” in Python
In Python "ImportError: cannot import name" error generally occurs when the imported class is not accessible, or the imported class is in a...
Read more >
ImportError: cannot import name X in Python [Solved]
The Python "ImportError: cannot import name" often occurs when we have circular imports (importing members between the same files).
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found