简体   繁体   中英

virtual environment in python3.4 won't import different modules

as a little disclaimer I'm completely new to both Linux/Terminal and Python, so excuse the imprecise terminology

I'm trying to follow the basic usage guide for the python-based scientific calculator PyPhi , a dedicated tool for calculated integrated information in a network. I've followed the installation guide , in which I brew installed the latest versions of python and python3 (2.7.9 and 3.4.2 at the time of writing), pip installed virtualenvwrapper, changed the ~/.bash_profile as suggested to

## Setting PATH for Python 2.7
# The orginal version is saved in .bash_profile.pysave
PATH="/usr/local/Cellar/python/2.7.9/Frameworks/Python.framework/Versions/2.7/bin:${PATH}"
export PATH
export PATH=/usr/local/bin:$PATH

export WORKON_HOME=$HOME/.virtualenvs
export PROJECT_HOME=$HOME/dev
source /usr/local/bin/virtualenvwrapper.sh

and also installed numpy for both 2.7.9 and 3.4.2. When I create a virtual environment using the command

mkvirtualenv -p `which python3` <name_of_your_project>

as suggested, I am able to import pyphi , but then attempting to import numpy as np brings up the error message

 File "<stdin>", line 1, in <module>
ImportError: No module named 'numpy'

This doesn't happen when I run python3 without a virtual environment, as I can import both pyphi and numpy. What's gone wrong with the virtualenvironment setup so that it doesn't work whilst in there?

Please refer this question , I think, you've got similar problem. There are two ways: quick&dirty and proper. Choose your own.

By the way, did you try adding Frameworks directory for 3.4.2 to $PATH ?

PyPhi author here—it looks like you correctly created the virtual environment but didn't install the package while it was activated.

Make sure the virtual environment is active by running workon <name_of_your_project before running pip install pyphi .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM