1

I am having trouble installing a custom python module I have written.

Here are my steps so far:

  1. Navigate to the module directory C:\Users\myname\repos\mymodulename where the setup.py file is in the anaconda prompt. Type: python setup.py install

The command prompt returns (plus some other things)

Extracting mymodulename-0.1-py3.7.egg to c:\users\myname\appdata\local\continuum\anaconda3\lib\site-packages
mymodulename 0.1 is already the active version in easy-install.pth
Installing myclass-script.py script to C:\Users\myname\AppData\Local\Continuum\anaconda3\Scripts
Installing myclass.exe script to C:\Users\myname\AppData\Local\Continuum\anaconda3\Scripts

Installed c:\users\myname\appdata\local\continuum\anaconda3\lib\site-packages\mymodulename-0.1-py3.7.egg
Processing dependencies for mymodulename==0.1

...

Using c:\users\myname\appdata\local\continuum\anaconda3\lib\site-packages
Finished processing dependencies for mymodulename==0.1

To me that looks like it has installed. Opening up the console and trying to import:

>>> import mymodulename.myclassas ce
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'mymodulename'
>>>

It appears in hasn't. Checking the list of modules in anaconda with help('modules') confirms that it has not been imported.

I thought that perhaps i had installed it to the wrong environment:

(base) C:\Users\myname>conda env list
# conda environments:
#
base                  *  C:\Users\myname\AppData\Local\Continuum\anaconda3
py2                      C:\Users\myname\AppData\Local\Continuum\anaconda3\envs\py2

Only a python 2 environment which mymodule wouldn't be compatible with.

Does anyone have any suggestions about what I can try to resolve this? Happy to elaborate on any of the points

Thanks in advance.

EDIT: Some more information that may be relevant.

This package was initially installed in site-packages. I have reinstalled there and the package works. The reason I moved the package is because I am aware it is bad practice to store custom packages there.

JDraper
  • 349
  • 2
  • 11
  • Just a couple of notes: 1. Using `pip install .` offers a few advantages over `python setup.py install`, see https://stackoverflow.com/a/15731459/6793245 2. You can run `conda list -n ` to list all packages installed in , if your package was successfully installed, it should be in that list. 3. It looks like your package was installed to the `base` env. Are you sure `base` was activated when you tried to import your package? 4. Could you elaborate on what you did with the `site-packages` folder? That's where packages go, where did you have it installed? Is the problem resolved now? – orangeInk Nov 06 '19 at 14:39
  • When I created the module, I first installed it in `site-packages` by doing the `python setup.py install` method. This worked fine, I realised that perhaps storing (and developing the module) from this location isn't the best idea. I copied and pasted the module to another area and tried to reinstall and that's where my question began. I have put the module back into the `site-packages` folder and it works fine. – JDraper Nov 06 '19 at 14:43
  • Perhaps I need to uninstall the module and then move the package? – JDraper Nov 06 '19 at 14:44

0 Answers0