I want to work with the python package holopy . Apparently you have to use conda to install it, so I first installed Anaconda 4.2.0 (since I'm using Python 3.5). I opened the virtual environment I normally use and installed holopy as they recommend on the official site:
conda install -c conda-forge holopy
Afterwards, when in the virtual environment I type conda list
, holopy shows up. But when I type python3
and then import holopy
, it says package not found. It does however work when I leave the virtual environment. I need it in the virtual environment though, how can I do that?
conda is a packaging tool and installer that aims to do more than what pip can do; handle library dependencies outside of the Python packages as well as the Python packages themselves. Conda also creates a virtual environment, like virtualenv does. For creating virtualenv with conda, use the following command:-
conda create -n yourenvname python=x.x anaconda
Use the following to activate the virtualenv in conda
source activate yourenvname
Then, you can install the packages in virtualenv using conda as:-
conda install -n yourenvname [package]
To Deactivate use:-
source deactivate
And to delete a no longer needed virtualenv, use :-
conda remove -n yourenvname -all
I'm not sure how well anaconda and virtual environments ie venv
work together. If you're using anaconda anyway then I highly recommend using anaconda environments. Please go through this short tutorial about anaconda environments - you won't regret it.
The conda
command is available only in the base anaconda environment. So when you run the command - conda insall -c conda-forge holopy
, it installed holopy
in the base anaconda environment and it won't be available to you in your venv
.
After looking at the documentation of holopy
it seems probable that when they said virtual environment
they actually meant anaconda virtual environment
. Therefore the solution is to first create an anaconda virtual environment
called holopy-env
and then run the command conda install -n holopy-env -c conda-forge holopy
.
I will also give you a quick and clean example of how to create an environment using anaconda. If you're using Anaconda then it would be wise to use it's environment management tools. Create an environment.yml
file with the following contents:
name: holopy-env # any name for the environment
channels:
- conda-forge
dependencies: # everything under this, installed by conda
- python=3.6
- holopy
- pip: # everything under this, installed by pip
- future
conda create --force -f environment.yml
source activate opencv-env
import holopy
pip install <package>
conda install -n holopy-env -c CHANNEL <package>
I know this is a bit late, but you don't need to use conda to install HoloPy. This is just the least technical option. Otherwise, you need to be able to compile HoloPy's fortran components yourself, which is fairly straightforward on Unix-based systems but complicated on Windows. Instructions can be found in HoloPy's documentation at https://holopy.readthedocs.io/en/latest/users/dev_tutorial.html .
We are also working on putting together a singularity container distribution of HoloPy. Let me know if this is of interest to you and I will make it a priority.
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.