/usr/bin/python3: Error while finding spec for 

2019-03-09 16:28发布

I'm trying to follow How To Serve Django Applications with uWSGI and Nginx on Ubuntu 14.04 and I'm failing at the very earlier stage, due to amount of output, I placed all related information into Pastebin.com - #1 paste tool since 2002!.

the actual error:

root@alexus:~# echo "source /usr/local/bin/virtualenvwrapper.sh" >> ~/.bashrc
root@alexus:~# source ~/.bashrc
/usr/bin/python3: Error while finding spec for 'virtualenvwrapper.hook_loader' (<class 'ImportError'>: No module named 'virtualenvwrapper')
virtualenvwrapper.sh: There was a problem running the initialization hooks.

If Python could not import the module virtualenvwrapper.hook_loader,
check that virtualenvwrapper has been installed for
VIRTUALENVWRAPPER_PYTHON=/usr/bin/python3 and that PATH is
set properly.
root@alexus:~#

I'm following how to to the teeth, what am I doing wrong?

8条回答
看我几分像从前
2楼-- · 2019-03-09 17:10

I had already installed virtualenv so just needed to run

pip3 install virtualenvwrapper
查看更多
该账号已被封号
3楼-- · 2019-03-09 17:17

This error appeared for me after running brew update and brew upgrade on mac os high sierra.

The issue was resolved by reinstalling virtualenvwrappper i.e. pip install virtualenvwrapper.

查看更多
Melony?
4楼-- · 2019-03-09 17:23

I faced similar problem, when using python3 with virtualenvwrapper,

sudo apt-get install python3-pip

Then install virtualenv and virtualenvwrapper from pip3,

sudo pip3 install virtualenv virtualenvwrapper

then source it again,

source .bashrc 
查看更多
兄弟一词,经得起流年.
5楼-- · 2019-03-09 17:29

check your python3 installation directory:

which python3

If installed by brew you should get:

/usr/local/python3

export python version to be used virtualenvwrapper:

export VIRTUALENVWRAPPER_PYTHON=/usr/local/python3

source your shell configuration file:
bash

source .bashrc

zsh

source .zshrc

查看更多
Root(大扎)
6楼-- · 2019-03-09 17:30

I encountered a similar issue with virtualenvwrapper complaining not being to find virtualenvwrapper.hook_loader. I was able to narrow down to this particular line in my .bash_profile

source /usr/local/bin/virtualenvwrapper.sh

as seen below

$ source /usr/local/bin/virtualenvwrapper.sh
/usr/local/opt/python3/bin/python3.6: Error while finding module specification for 'virtualenvwrapper.hook_loader' (ModuleNotFoundError: No module named 'virtualenvwrapper')
virtualenvwrapper.sh: There was a problem running the initialization hooks. 

If Python could not import the module virtualenvwrapper.hook_loader,
check that virtualenvwrapper has been installed for
VIRTUALENVWRAPPER_PYTHON=/usr/local/bin/python3 and that PATH is
set properly.

After some trial and error, it turns out that a reinstallation of the virtualenvwrapper package resolved it. This was a manifest of the fact that I recently upgrade python3 (from version 3.5.2 to 3.6.1) via homebrew and in turn it broke virtualenvwrapper's shell script that hardcoded references to the older version of python3 (in my case it was 3.5.2). In short, this below line should fix it (at least in my case it did).

pip3 install virtualenvwrapper
查看更多
贪生不怕死
7楼-- · 2019-03-09 17:31

Thanks to @Alexander, I was able to fix my issue by changing:

export VIRTUALENVWRAPPER_PYTHON=/usr/bin/python3

to

export VIRTUALENVWRAPPER_PYTHON=/usr/bin/python

due to backwards compatibility.

查看更多
登录 后发表回答