Why does Anaconda have two site-packages libraries? - python

C:\ProgramData\Miniconda3\pkgs\plotly-3.1.1-py36h28b3542_0\Lib\site-packages\plotly
C:\ProgramData\Miniconda3\Lib\site-packages\plotly
What is the difference between these?
my code tries to pull from the second location but doesnt find things.
for example, it will tell me my module 'plotly.figure_factory' has no attribute 'create_choropleth' or something
so I transferred the files from the first location to the second one and it found them.

Pkgs directory is somewhere to place the package downloaded and unzipped. So it is a full and complete scripts/project documents.
Actually, the second one should have the file you want if you installed the package properly. I think maybe there are some problems during installing or you just install it into some sub-environment of miniconda instead of the global environment of miniconda. So there will be some left packages which are downloaded and unzipped but not installed.
You could also copy and paste the file from the first location to the second one by yourself. If you could import properly, it should be ok.

Related

[WinError 123} Can't install pip packages

I tried to find solutions on simillar threads but really can't find any.
Can't install packages due to an error WinError 123 as shown on image below:
Image here!
I find it weird that in path there is 'sC' term at the end.
I tried to reinstall and install different versions of python but it happens on all as I assumme that is a Windows problem.
ENV definitions pt.1
ENV definitons pt.2
During investigation i put print command in path and mkdir function variable called 'name'. Everything goes well over there but i found a problem at last few lines:
Problem
So the last Path is corrupted as it adds a 's' character and repeats the path again, and when tool is cropping the path it leaves it with just sC signs.
Well... it took rather longer distance than i thought and of course the answer is simple.
Easiest way is to run:
pip config debug
and localize your installing paths:
Here is the output:
I saw there was a weird one over there at global.target variable which I did not modify. Easy solution, just change pip.ini file so the path is actually the path you want your libraries to be stored at.

pip install, How to fix ImportError

I'm having ImportError: cannot import name 'Literal' from 'typing' error message when I try to use pip install. Anyone can help?
The problem is with the configuration of your environmental variables. The first thing, I'd suggest you do is uninstall all the unused versions of python. To my mind, the latest of python 3.x.x series is the best.
Steps:
The easiest way of accessing it is just to type environment variable in Windows 10 search bar. (Assuming you are using Windows 10)
Then follow these:
At the bottom half part of the subsequent window search for path:
If you double click that, look for python. Make sure you have such paths added there and you need to have a compatible version of python. Usually, your python bin directory is located in Program Files.

Jupyter-notebook returns "module not found" for every single import, despite them being downloaded

For example, import trackpy returns the module not found error.I have already confirmed that trackpy has been downloaded somewhere on my computer, because attempting to install it again via conda install -c soft-matter trackpy will eventually return something to the effect of "all files already installed". This seems to occur for every "external import" (numpy, scipy, matplotlib), i.e. one that was downloaded somewhere from the internet. This does not happen for "internal imports" (sys, os). I believe this is just a matter of jupyter not looking for the files in the correct place, but I don't know how to fix something like this.
Edit: Relevant info: I ran
import sys
sys.executable
which returns 'c:\\users\\reese\\miniconda3\\python.exe'. In the pkgs folder for miniconda3, there are none of the imports that I want. However in 'c:\\users\\reese\\Anaconda\\pkgs' are all the imports, trackpy and all else. Is there an easy way to make jupyter check here for imports? I already tried straight up copying the entire pkgs folder and pasting it in miniconda3's pkgs folder, but it did not work.
Two solutions I would propose.
Okay Solution:
Yes, you can add the path to your other packages with sys.path:
import sys
sys.path.insert(0,'PATH_TO_YOUR_OTHER_PACKAGES')
import Packages_of_another_path
By insert it at index zero, you ensure that your other packages get first priority in case there in another package with the same name.
Better Solution:(Recommendable)
Always use environments. E.g.
conda create —name your_env python=3.6 pip
conda activate your_env
conda install packages1 packages2
pip install package3
In this environment you can keep all you things together.
Everything you wish to use your packages, activate your environment and start hacking ;)

Cannot install via pip within virtualenv

so I tried to set up an working environment to code some stuff with python. I used this really nice website newcoder.io to do it the right way.
Unfortunately I came across a big problem I cannot solve by myself even after several hours of trial and error (sponsored by Google).
I installed all required packages starting from python, virtualenv, virtualenvwrapper. I also changed the .bashprofile for using Terminal as stated. Then I tried to test the working environment like described in the aforementioned website newcoder.io Test.
As I was within the working environment named "TestEnv" I tried to install django via pip. Here is the result coming from Terminal:
(TestEnv)username:~ username$ pip install django
-bash: /Users/username/.virtualenvs/TestEnv/bin/pip: "/Users/brokenusername: bad interpreter: No such file or directory
As you can see there seems to be something wrong with the underlying links. I have to admit, that I recently changed my account name and the name of the home directory in OS X Mavericks (see "username" and "brokenusername" within the code). Everything went fine so far. The username is now without blank spaces in the name (a different, bigger problem, but solved). But pip still seems to keep the old "brokenusername".
My Question is, how do I change the "brokenusername" to "username" so that pip is able to its work.
Thanks for all advices.
Here is a sloth for all your efforts to help !
Please note: I am newbie when it comes to understand and change these kind of working environments. I tried my best to find a solution by myself. But it seems like I need some advice from the Internetz.
virtualenv creates symlinks, environment variables and other path links in places like .pth files that are invalidated when you change the base path of the env. But environments are cheap to create so (assuming you haven't placed other files in the virtualenv directory) just delete it and build it again.

Where are Pypi packages installed by default?

I am new to programming and Python and what's really bothering me is that on my Mac, I'm used to knowing exactly where everything is and what's in every folder, but doing things through the command line is very different, so I don't know where things like Python Packages are being installed to by default.
According to the Pypi site, the packages are installed here: /usr/local/lib/python2.3/site-packages'
However when I cd to /usr/local/lib/, all I see in this folder are 'wx-python unicode', which I'm guessing was an accident on my part because I forgot to activate my virtual environment when I installed it?
Why is nothing in my /lib/ folder?
If you ever want to know where a module source file is located:
import some_module
print some_module.__file__

Categories

Resources