I'm currently trying to build a conda virtual environment for a project. However some packages are still not possible to install with the pip and conda commands (such as pyqt5 or liblsl for instance), but these are necessary for the project.
I tried to install these packages using the brew install command, while being in the virtual environment, but the packages do not appear in the conda virtual environment.
So, do you know if it is possible to install packages with the brew command and include it in the virtual environment ?
Related
I installed miniforge on my Mac M1 and created an environment.
conda create --name myenv
conda activate myenv
In this environment, I installed python and pip. There are some packages specifically available on pip, so I did a pip install -r requirements.txt, assuming that these packages would be dumped in the myenv environment.
However, when I do conda list, I am getting only pip as the installed package and pip list is giving me all the installed packages.
When I checked the path, my conda environment is in this path -
~/miniforge3/envs/myenv/bin/python
while my pip is in
/Users/I323017/Library/Python/3.8/lib/python/site-packages/pip
Could you please help me to create my pip env under the conda environment by default.
I was finally able to fix the issue.
When I do just pip install <package_name> within my environment, the package still gets installed in
/Users/I323017/Library/Python/3.8/lib/python/site-packages/pip
However, if I do python -m pip install <package_name> within my environment, the package will get installed under the environment directory.
I am using conda as the Python3 package management tool, sometimes the conda repo did not contains some Python package. So I have to install it using pip, first I found the anaconda environment folder, the next step switch to the anaconda environment folder:
cd /usr/local/anaconda3/envs/pydolphin
then using this command to install package:
./bin/pip install musicbrainzngs
is there any short way to do this? is it possible to install it the PyCharm IDE the simple way? the PyCharm IDE using conda install by default.
First activate your conda environment:
conda activate <env>
This will switch to the version of pip installed in this environment. Then you can install using pip as per normal which will install it into your conda environment:
pip install musicbrainzngs
virtualenv
We will activate the virtual environment first and then run pip install ... to install packages for virtual environment.
See the document, https://packaging.python.org/guides/installing-using-pip-and-virtual-environments/
source env/bin/activate
Now that you’re in your virtual environment you can install packages. Let’s install the excellent Requests library from the Python Package Index (PyPI):
pip install requests
But pipenv is different.
pipenv
As for pipenv, the instruction here, Please explain the usage of Pipfile and Pipfile.lock
Before we activate the virtual environment,
We could run pipenv install to install packages in the project folder first.
Then we can run pipenv shell to activate the virtual environment.
In other words, using virtualenv, we create/activate virtual environment first, and then pip install ... packages in virtual environment. But using pipenv, we use pipenv install ... to install packages in the project folder first and then use pipenv shell to active the environment.
Is this correct?
Er, basically yes.
Virtualenvs change the environment in your current shell, which you can undo with deactivate, whereas pipenv shell creates a new shell that you need to exit when you have finished.
I have installed the pygal package through the following command line:
conda install -c akode pygal
However, when I search this package in the Anaconda, I can only find this package in the base (root) environment. When I try to search this pygal package in my newly created environment, nothing can I find.
Why does this happen? and is there any solution to this problem?
When you are not in an environment and run conda install , it will install it in the base. If you activate your environment then install the package using conda install, it will apply to your environment.
source activate data_visualization_coursera
conda install -c akode pygal
Or you can install a specific package to an environment using this command
conda install -n <environment_name> <package_name>
You can find all of the documentation here https://conda.io/docs/user-guide/tasks/manage-environments.html
I have a python project that uses virtualenv. I have installed various packages using pip install <package-name> with the virtual environment activated. I now want to generate a list of these packages. I am using the command pip freeze >requirements.txt (again with the virtual environment activated) however when I open the file all I see is:
virtualenv==15.1.0
I don't see any of the other packages I have used. What am I doing wrong here?