Problems with virtual envs after upgrading linux xubuntu 18.04, PyCharm 2018.1

Answered

I've been using PyCharm (now Pro 2018.1) for some time on Xubntu 16.04LTS, I have just upgraded to 18.04LTS and found that the virtual environments that I had been using without problem fail with the message

    ImportError: cannot import name _remove_dead_weakref

A search reveals that this typically happens when the host python version is no longer the same as that in the venv (which seems to reduce the values of venvs...but that's a different matter and nothing to do with PyCharm). I did see some recipes for upgrading a venv and generating requirements'txt files from the old venvs in order to  create a compatible new venv but at first I needed a new venv.

And so I started up a brand new venv, created afresh in PyCharm. This seemed OK and I started by trying to install PySide 1.2.4 from the package list (my current projects use PySide) but now it reports

    AttributeError: 'module' object has no attribute 'main'

with a comment (some path elements removed)

    Try to run this command from the system terminal. Make sure that you use the correct version of 'pip' installed for your Python interpreter located at '/.../<venv>/bin/python'.

and the details

  Traceback (most recent call last):
  File "/..../software/pycharm-2017.3.2/helpers/packaging_tool.py", line 192, in main
    retcode = do_install(pkgs)
  File "/..../software/pycharm-2017.3.2/helpers/packaging_tool.py", line 109, in do_install
    return pip.main(['install'] + pkgs)
AttributeError: 'module' object has no attribute 'main'

(You will note above the references to 2017.3.2, I cannot recall but I presume the 2018.1 upgrade was a patch and just amended the 2017.3.2 binaries etc.)

And so I type the command at the PyCharm terminal window, in the same venv of course. As I type this it is going through the process of installing PySide so I presume that the issue with Pip has been overcome. Perhaps I should have started with a simpler install - I know that Pyside does take a while...

But this does seem rather more that just an irritation, I have twenty or so packages to install and while typing the commands will not be a major issue the failure does make me worry about what is going on if the fresh venv, only just created by PyCharm, doesn't contain the correct software versions, will any upgrades to the ackages, as does happen quite often in Python work or not ?

Any suggestions ?

graham

 

6 comments
Comment actions Permalink

Unfortunately there is still an issue despite the fresh venv as described; when I load the project I get

21:43    Could not execute hg status command : [abort: cannot import name _remove_dead_weakref!]

21:43    Could not execute hg status command : [abort: cannot import name _remove_dead_weakref!]

21:43    Error during log command execution: [abort: cannot import name _remove_dead_weakref!]

21:43    Error during log command execution: [abort: cannot import name _remove_dead_weakref!]

Obviously I use Mercurial...I can actually issue 'hg status' from the terminal and this appears to work correctly.

 

0
Comment actions Permalink

Could you please create a ticket in our bug tracker and attach idea.log from Help | Show Log in ...? The original error sounds like https://youtrack.jetbrains.com/issue/PY-29395, could you please specify the exact version of PyCharm you are using?

0
Comment actions Permalink

Sorry - do you mean for the original post or my second dead_weakref comment ?

In fact I must withdraw my second _remove_dead_weakref comment as an issue...while driving to the local town to buy milk yesterday (oh the joys of rural living, 10 km for milk) I suddenly realised what the problem was: as I said I created a fresh venv but had forgotten that the Mercurial binary would have been set to the default (probably in /usr/bin... ) when I set it to the newly installed Mercurial in that new venv and reloaded the project the _remove_dead_weakref error did not occur

 

graham

0
Comment actions Permalink

>Sorry - do you mean for the original post or my second dead_weakref comment ?

The original one, yeap, sorry for the obscure comment.

0
Comment actions Permalink

Just created the bug; but, indeed, it does appear to be the same as the one your mention, it gives the same line numbers etc.

0
Comment actions Permalink

I got the same problem. Some workaround?

0

Please sign in to leave a comment.