[PYTHON] (Note) How to pass the path of your own module

Don't forget to install Elcapitan and re-install it.

goal

Import your own library as follows.

import hge

Also, use your own module as follows.

$ etti.py

Find out the search path

Check the search path with a script like the following.

test.py


import sys
A= sys.path
for i in A:
	print i
$ python test.py 
/Users/XXXXX/Desktop
/Users/XXXXX/.pyenv/versions/2.7.10/lib/python27.zip
/Users/XXXXX/.pyenv/versions/2.7.10/lib/python2.7
/Users/XXXXX/.pyenv/versions/2.7.10/lib/python2.7/plat-darwin
/Users/XXXXX/.pyenv/versions/2.7.10/lib/python2.7/plat-mac
/Users/XXXXX/.pyenv/versions/2.7.10/lib/python2.7/plat-mac/lib-scriptpackages
/Users/XXXXX/.pyenv/versions/2.7.10/lib/python2.7/lib-tk
/Users/XXXXX/.pyenv/versions/2.7.10/lib/python2.7/lib-old
/Users/XXXXX/.pyenv/versions/2.7.10/lib/python2.7/lib-dynload
/Users/XXXXX/.pyenv/versions/2.7.10/lib/python2.7/site-packages

Pass through

Add mymodules.pth to site-packages in the searched directory. The content describes the location where the self-made module is placed (~ / .mymodules in my case).

mymodules.pth


~/.mymodules

Also, add the following to .bash_profile. (If you can't use it with ʻetti.py`, check the permissions.)

export PATH=$PATH:/Users/XXXXX/.mymodules

Recommended Posts

(Note) How to pass the path of your own module
Make the theme of Pythonista 3 like Monokai (how to make your own theme)
How to access the global variable of the imported module
[Selenium] How to specify the relative path of chromedriver?
[Ansible] How to call variables when creating your own module
How to use the optparse module
How to create your own Transform
Hook to the first import of the module and print the module path
How to use the ConfigParser module
How to check the version of Django
To import your own module with jupyter
Check the path of the Python imported module
How to install your own (root) CA
"How to pass PATH" to learn with homebrew
I tried how to improve the accuracy of my own Neural Network
How to calculate the volatility of a brand
How to find the area of the Voronoi diagram
How to define your own target in Sage
How to add a Python module search path
To get the path of the currently running python.exe
Create a wheel of your own OpenCV module
How to pass the path to the library built with pyenv and virtualenv in PyCharm
Note: How to get the last day of the month with python (added the first day of the month)
How to run the Ansible module added in Ansible Tower
How to get the number of digits in Python
How to use the Raspberry Pi relay module Python
How to visualize the decision tree model of scikit-learn
[Blender] How to dynamically set the selection of EnumProperty
Call your own python module from the ROS package
[Python] Summary of how to specify the color of the figure
How to hit the document of Magic Function (Line Magic)
Python Note: The mystery of assigning a variable to a variable
How to avoid the cut-off label of the graph created by the plot module using matplotlib
How to change the generated image of GAN to a high quality one to your liking
How to find the optimal number of clusters in k-means
How to test the attributes added by add_request_method of pyramid
How to use the generator
Make the display of Python module exceptions easier to understand
How to use pyenv and pyenv-virtualenv in your own way
How to calculate the amount of calculation learned from ABC134-D
[Note] How to use virtualenv
How to summarize the results of FreeSurfer ~ aparc, aseg, wmparc ~
How to run the Export function of GCP Datastore automatically
How to increase the number of machine learning dataset images
How to see the contents of the Jupyter notebook ipynb file
How to find the scaling factor of a biorthogonal wavelet
How to get an overview of your data in Pandas
How to use the decorator
Try HeloWorld in your own language (with How to & code)
How to pass the execution result of a shell command in a list in Python (non-blocking version)
How to increase the axis
How to start the program
How to connect the contents of a list into a string
How to handle multiple versions of CUDA in the same environment
How to determine the existence of a selenium element in Python
How to implement Java code in the background of RedHat (LinuxONE)
[Note] Let's try to predict the amount of electricity used! (Part 1)
How to pass and study the Python 3 Engineer Certification Basic Exam
A note on how to check the connection to the license server port
How to know the internal structure of an object in Python
How to pass VScode + WSL + Python Path (Unable to import ~ "xxx" solution)