pycharm packages not displayed in the project interpreter window - import

I am using pycharm 5.0.4 community edition.
I wanted to install package fuzzywuzzy.
But when i go to project interpreter window and try to install package, it shows me no available packages.
Can it be issue because I am using my work desktop.
Thanksenter image description here

Can you provide more details- Are you not able to see any packages? Try searching for some other packages like pip, matplotlib, django, numpy etc. Sometimes it takes time for the IDE to build skeletons before you can actually start installing the packages. So once the IDE wait for it to complete its setup and then try to access the installation packages available.
Also if you do you have any other python interpreter installed on your local machine? If so then try switching to that interpreter.

Below are some steps you can try, which worked for me:
Step-1 Activate your intelpython using:
source <your installation path>/bin/activate
Step-2 Clone the environment using conda clone command and make sure the pwd is ~/:
conda create -n <source_environment> --clone <destination_environment>
Step-3 Activate the cloned environment:
source ~/.conda/envs/<your_environment>/bin/activate
Step-4 Provide read-wite permissions to intelpython and cloned enviroment using:
sudo chown -R <user_name>:<group_name> /<path_to_directory i.e. /opt/intel and ~/.conda/envs>
Step-5 Open Pycharm and in System Interpreter add the path to above created enviroment and then you can use pip or Pycharm itself, it should work.

I had a similar problem. I was using the Intel python distribution, and installing packages required write permissions to the folder that intelpython was installed in, which in my case was /opt/intel/intelpython2.
Try adding write permissions to the folder using the following command:
sudo chown -R <username> </path/to/folder>
Then try adding missing packages and/or repositories as seen in this page - https://www.jetbrains.com/help/pycharm/installing-uninstalling-and-upgrading-packages.html.

Related

Cant use **!** for pip install in Jupyter

I am trying to use ! git clone to clone a repository into a specific directory.
But I noticed I can't use ! at all in my Jupyter Lab. The code runs with no error but nothing gets printed out. I double confirmed this using !pip list.
The actual code I am trying to run is
LABELIMG_PATH = os.path.join('Tensorflow', 'labelimg')
if not os.path.exists(LABELIMG_PATH):
os.makedirs(LABELIMG_PATH)
! git clone https://github.com/tzutalin/labelImg {LABELIMG_PATH}
But it runs instantly creating the labelimg folder without running the git clone code.
for !pip list it also runs instantly without printing any packages in the output cell.
I have checked and the virtual environment is being used in the kernel, I thought it was because of ipykernel packages and installed the few lines of code below.
conda install -c conda-forge pywin32
conda install -c anaconda jupyter_client
conda install -c conda-forge jupyter_core
But after rebooting it still didn't work. I checked other virtual environments and ! pip list also didnt work.
I also tried ! pip3 list, !pip list, !pip3 list and it all didn't work.
Would really appreciate any help. Thank you!
EDIT:
line 10 is the code I wish to use to clone the repo, line 13 is the next line which I have not run kindly ignore, the purpose was to show the output of line 10, as you can see it runs successfully almost instantly with no output
But the folder is empty and nothing is cloned.
As far as I know, if you want to run pip install of any sort you need not add a "!"
You just directly run pip install
"!" prefix commands as mentioned are special to be used in a particular code block with git and other similar commands.
If you want to clone the repo from your python code, use the library -> GitPython
from git import Repo
Repo.clone_from("git path here", "directory to clone to")

Not able to install feature -Engine Module

I am trying to install feature-engine module on anaconda
this is the error i am getting
Package is not available from current channels
repo.anaconda win 64 , noarch etc.
Can you please help me with the problem?
Thanks,
RD
to install from anaconda:
conda install -c conda-forge feature_engine
I believe that feature-engine is not available through anaconda channels for installation with conda install. I was able to install it via pip. Here is how I did it (in Windows):
open a CMD and run conda activate <<VIRTUALENV>>. This is the environment you create for your project. If you have not created one, then use base, the default one.
cd to the location of your pip installation within that activated conda Virtual environment (mine was within my user folder in \AppData\Local\Continuum\anaconda3\envs\<<VIRTUALENV>>\Scripts).
in there, run pip install feature-engine
you should now be able to see it listed under pip freeze or pip list, but not under conda list.
Finally, go to your code location and run the code. remember to activate that same <> each time you open a new CMD to run it.
Hope it helps.
If you are using Jupyter Notebooks, it might be the case that your Jupyter Notebook is not actually running the kernel in your (activated!) Anaconda environment (via this answer), but the generic Python3 kernel that only can import packages from your global Anaconda environment.
You can check for this by importing a package that is installed in your global environment (e.g., pandas), while running a notebook:
import pandas
pandas.__file__
If you see something likes this (on Windows), you are indeed running the wrong kernel (as you would expect the packages to be loaded from the activated environments):
'C:\\Users\\<user>\\Anaconda3\\lib\\site-packages\\pandas\\__init__.py'
Therefore, in your Anaconda Prompt, you have to create a new kernel within ipykernel (assuming cenv is your environment of interest):
$ conda activate cenv # . ./cenv/bin/activate in case of virtualenv
(cenv)$ conda install ipykernel
(cenv)$ ipython kernel install --user --name=<any_name_for_kernel>
(cenv)$ jupyter notebook
Now, in the restarted Jupyter Notebook you can change the kernel via the menu: Kernel > Change kernel > <any_name_for_kernel>
Importing the same package, like pandas, should show the following file path:
'C:\\Users\\<user>\\Anaconda3\\envs\\<cenv>\\lib\\site-packages\\pandas\\__init__.py'
and you should be able to import any package installed in that Anaconda environment.

simpleitk installation in anaconda

i installed simpleitk in anaconda using command
conda install -c simpleitk simpleitk then followed link https://github.com/SimpleITK/SimpleITKCondaRecipe to build it but it's not connecting to itk.org to build.
import SimpleITK as sitk on jupyter notebook is working but sitk.show() is not working. moreover when i tried to follow the commands from http://insightsoftwareconsortium.github.io/SimpleITK-Notebooks/Python_html/00_Setup.html,
from downloaddata import fetch_data, fetch_data_all not working.
even the command fetch_data_all(os.path.join('..','Data'), os.path.join('..','Data','manifest.json')) is not working. i am very new to simpleitk and don't know whether it is due to build not processed. please tell me how to solve my problems. i have been trying from many days, pl help me. moreover how to make imagej as default for simpleitk. i know lots of questions but i would be greatful if solved.
You seem to be having multiple problems, all of which have to do with installing a working environment and less specific to SimpleITK.
You installed SimpleITK using the conda install command, so there was no need to build it using the conda build command. Check that you have it installed correctly and see which version you have:
import SimpleITK as sitk
print(sitk.Version())
The functions fetch_data and fetch_data_all are part of a module found in the SimpleITK notebooks repository. To use the code from that repository you will need to clone it using git:
git clone https://github.com/InsightSoftwareConsortium/SimpleITK-Notebooks.git
Then you can run the notebooks or copy the relevant modules to your directory and work with them there.
The sitk.Show() command assumes that you have the ImageJ/Fiji program installed which is likely why it is not working (I am guessing here as you did not provide sufficient detail).

There is no activate when I am trying to run my virtual env

1) I installed virtualenv using pip.
2) I ran the command virtualenv venv
3) Then I ran source venv/bin/activate but it says that there is no such file or directory.
When I cd into venv/bin I find 3 things - python, python 2.7, and python 3.5. Does anyone know the problem?
i have had the same problem. and what i did is just run the command
virtualenv env
again. And then more files were generated under directory env/bin, including the activate file. it's so weird.
I solved the similar problem running python3.7 -m venv venv, you can change for your version of python that is installed in your enviroment.
According to Python doc, the installation step is
$ python3 -m pip install --user virtualenv
$ python3 -m venv env
The last command gives a warning message,
The virtual environment was not created successfully because ensurepip is not
available. On Debian/Ubuntu systems, you need to install the python3-venv
package using the following command.
apt-get install python3-venv
You may need to use sudo with that command. After installing the python3-venv
package, recreate your virtual environment.
$ sudo apt-get install python3-venv
Now, activate is available.
I solved a similar problem by naming it venv2 when I ran virtualenv. I already had a virtual environment named venv for another project. This allowed me to proceed.
I experienced this problem when using the --upgrade option. Removed the option, and all ran as expected.
I double it is caused by some networking issue, I run it twice to get 'activate' script installed. Maybe first it can't connect to some source so it just abort installation.
I had this happen on rasbian when I hadn't installed python3-pip before creating the venv.

Installing with PIP in virtualenv?

I'm trying to wrap my head around virtualenv and pip still.
If I use pip to install a library, it doesn't matter where I 'cd' to, because it installs the libraries in the same place right (which i dont even know where that is)? So I guess my question is, when I install something with pip, how do I make sure it only installs that library inside of my virtual environment? Do I need to cd to that directory first? or is there a command I'm supposed to use with pip to make sure it only installs to the virtualenv project I'm working in?
Activate virtualenv first:
source virt_name/bin/activate
Then after that, install the libraries:
pip install module_name
Note: Don't use sudo with pip because sometimes it will assume you want to install in /usr/local/lib/site-packages.
Generally speaking, if you do not use virtualenv --system-site-packages to create your virtualenv, you should be only working with your per-environment packages.
Providing you run the activate script before installing anything.
i.e. Do the following, if you want to install something in your virtualenv.
Run activate script
Windows: [ve_directory]\Script\activate.bat
Linux: source [ve_directory]/bin/activate
pip install [your requirements]
I think it doesn't matter where your current working directory is.
Reference:
http://www.virtualenv.org/en/latest/#the-system-site-packages-option
When you create a new environment with virtualenv, among other things it creates a bash script venv/bin/activate (where venv is the folder you specified when you created the environment; libraries are located there as well, by the way). When you run it in your shell the environment variables become arranged so that pip installs new libraries in this environment's folder. See virtualenv docs for details, section "activate script".